我正在使用HTML 5和Perl Web服务器套接字。套接字服务器可以知道用户何时关闭浏览器吗?请帮忙服务器:
Net::WebSocket::Server->new(
listen => 8080,
on_connect => sub {
my ($serv, $conn) = @_;
$conn->on(
utf8 => sub {
my ($conn, $msg) = @_;
$conn->send_utf8($msg);
},
disconnect => sub {
my ($conn, $code, $reason) = @_;
$conn->disconnect();
},
);
},
)->start;
是的。为套接字上的 disconnect
事件设置处理程序:
$conn->on(
disconnect => sub {
my ($conn, $code, $reason) = @_;
...
},
);