engine.io
engine.io copied to clipboard
Why you don't use cookie stored socket ID?
Hi, I use a socket.id as ID of the session. And I need to after refresh the page, socket is created based on the already generated ID (stored in client cookie). In your code you are saving ID, but do not use it for a new connection. Why not use something similar? (possibly optional)
Server.prototype.generateId = function(req){
var c = parseCookie(req.headers.cookie);
if(this.cookie && c[this.cookie]){
return c[this.cookie];
}
return base64id.generateId();
};
Or maybe something like this already implemented and configured?
You're right, the default behaviour is to generate a new id on reconnection. You can provide your own generateId method though:
var engine = require('engine.io');
engine.generateId = <your custom function>
Please see the sample test case.