Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get session id of socket.io client in Client

I want to get session id of client in my socket.io client.

here is my socket.io client :

var socket = new io.Socket(config.host, {port: config.port, rememberTransport: false});     // when connected, clear out display     socket.on('connect',function() {         console.log('dummy user connected');     });     socket.on('disconnect',function() {         console.log('disconnected');     });     socket.connect();     return socket; 

I want to get session id of this client , how can i get that ?

like image 503
XMen Avatar asked Aug 08 '11 09:08

XMen


People also ask

How do I know if socket.io client is connected?

You can check the socket. connected property: var socket = io. connect(); console.

How do I connect socket.io to client side?

var socket = require('socket. io-client')('ws://ws.website.com/socket.io/?EIO=3&transport=websocket'); socket. on('connect', function() { console. log("Successfully connected!"); });

How do I monitor socket.io traffic?

Use Monitor.io to observe connections and replay messages It shows a list of active Socket.io client connections for your application. You can use the monitoring interface to broadcast messages–either globally or to a specific client.


1 Answers

Have a look at my primer on exactly this topic.

UPDATE:

var sio = require('socket.io'),     app = require('express').createServer();  app.listen(8080); sio = sio.listen(app);  sio.on('connection', function (client) {   console.log('client connected');    // send the clients id to the client itself.   client.send(client.id);    client.on('disconnect', function () {     console.log('client disconnected');   }); }); 
like image 94
Daniel Baulig Avatar answered Oct 11 '22 18:10

Daniel Baulig