我正在使用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;
答案 0 :(得分:1)
是。在套接字上为the disconnect
event设置处理程序:
$conn->on(
disconnect => sub {
my ($conn, $code, $reason) = @_;
...
},
);