Question

I want to create only one connection from one ip-address? If there is a connection in the first window, but the user creates a new connection in a second window, then make the change and return to the old connection. Is it possible?

var sessions = {};

io.sockets.on('connection', function (socket) {
  var address = socket.handshake.address.address;

  if (sessions[address]) {
    // what can I do here?
  }

}
Was it helpful?

Solution

It's not documented, but you can use socket.disconnect(); to send a disconnect message to the client (graceful disconnection) or you can call socket.disconnect(true); to provide a forceful/abrupt disconnection.

Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top