force client disconnect from server with socket.io and nodejs

Any reason why you can't have the server emit a message to the client that makes it call the disconnect function?

On client:

socket.emit('forceDisconnect');

On Server:

socket.on('forceDisconnect', function(){
    socket.disconnect();
});

socket.disconnect() can be used only on the client side, not on the server side.

Client.emit('disconnect') triggers the disconnection event on the server, but does not effectively disconnect the client. The client is not aware of the disconnection.

So the question remain : how to force a client to disconnect from server side ?


Edit: This is now possible

You can now simply call socket.disconnect() on the server side.

My original answer:

This is not possible yet.

If you need it as well, vote/comment on this issue.

Tags:

Socket.Io