I am passing a custom query string containing an identifier to authorize the client on the server when it connects via socket.io.
var env = {id:12345}; var socket = io.connect('https://example.com', {query:'i='+env.id, port:443, reconnect:false, secure:true});
When a client disconnects for any reason, it can reconnect simply by calling the following function.
socket.socket.connect();
However, during reconnection, env.id usually contains a different value than during initial reconnection, and I want to have the current value in the query string for every reconnection.
The above reconnection method sends the initial value again, even if env.id been changed to another value.
I tried to set the current parameters when calling the reconnect function, but this does not work.
socket.socket.connect('https://example.com', {query:'i='+env.id, port:443, reconnect:false, secure:true})
Is there an easy way to update the query string with the current value of env.id and then reconnect?
Or do I need to destroy the entire socket object after disconnecting it, and then create a new connection using var socket = io.connect() with the current identifier?
1nsane
source share