Pregunta

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

}
¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top