문제

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