1

Can someone tell me how to get disconnect event with socket.io with xhr-polling in node.js please?

This example not working with xhr-polling but works with 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']); // If I change it to websockets it works!

// 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");
    });
});

So how to get disconnect event with xhr-pooling?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
julian
  • 4,634
  • 10
  • 42
  • 59
  • http://stackoverflow.com/questions/12043893/socket-io-force-a-disconnect-over-xhr-polling – Tamas Jul 26 '13 at 14:08

0 Answers0