【发布时间】:2013-07-25 14:23:02
【问题描述】:
有人可以告诉我如何在node.js 中使用socket.io 和xhr-polling 获取断开连接事件吗?
此示例不适用于 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 获取断开连接事件?
【问题讨论】:
标签: javascript node.js socket.io dom-events