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?
  }

}
有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top