Send additional data on socket connection

You should send your data either in connect or on create:

var s = io('http://216.157.91.131:8080/', { query: "foo=bar" });
s.connect();

var c = io.connect('http://216.157.91.131:8080/', { query: "foo=bar" });

With the new version of socket.io, on server is where the things have been changed:

var io = require('socket.io')(server);

io.use(function(socket, next) {
  var handshakeData = socket.request;
  console.log("middleware:", handshakeData._query['foo']);
  next();
});

Leave a Comment