有人可以告诉我如何socket.io
使用xhr-polling
in获取断开连接事件node.js
吗?
此示例不适用于xhr-polling
但适用于websockets
..
/* Basics */
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server);
server.listen(1337, null);
io.set('transports', ['xhr-polling']);
// routing
app.get('/', function (req, res) {
res.sendfile("index.html");
app.use(express.static(__dirname));
});
var online_clients = 0;
io.sockets.on('connection', function (socket) {
socket.on('disconnect', function() {
console.log("SOMEONE LEFT");
});
});
那么如何获得断开事件xhr-pooling
呢?