engine.io-server-java
engine.io-server-java copied to clipboard
How to reject a client connection?
Hi, how to reject a client connection properly? I have something like this:
SocketIoNamespace ns = mSocketIoServer.namespace("/");
ns.on("connection", args -> {
SocketIoSocket socket = (SocketIoSocket) args[0];
//verify JWT token
if (isTokenInvalid()) {
socket.disconnect(true);
}
})
socket.disconnect(true) doesn't interrupt the whole connection process, so I am not sure if it's correct solution (e.g. disconnect() method clears mSockets Map inside SocketIoClient, but right after that, method onConnect() put something to that map and the rest of the connection process takes place).
Thanks for answers.
Hi, I've updated the mechanism in the latest release to allow this use case. Please check it out.