SocketCluster / socketcluster-client

JavaScript client for SocketCluster
MIT License
291 stars 92 forks source link

socket.deauthenticate([callback]); callback don't work properly #63

Closed willypuzzle closed 7 years ago

willypuzzle commented 7 years ago

I need to deauthenticate the socket before to use it but even when callback is called, sometimes, the socket is not deauthenticated.

for example:

socket.deauthenticate((err) => {
     if (!err){
         console.log(socket.getAuthToken()); //it returns a object instead of null
     }
})
jondubois commented 7 years ago

@willypuzzle The callback is called just before the token is removed from the client (but the socket is already deauthenticated from the server-side). If you add a setTimeout(fn, 0); the token on the client will be gone.

I guess we should change it to trigger AFTER the token was removed - That would be less confusing.

jondubois commented 7 years ago

@willypuzzle I updated it in socketcluster-client v5.0.10