I'm looking for some help figuring out sessions on a server that relies on express and socket.io. Mostly the goal is handling things like pairing socket.io session ids with user ids, maintaing state on reconnects, and being able to easily group any actors on the server.
Any help is very much appreciated.
Thanks.
I'm looking for some help figuring out sessions on a server that relies on express and socket.io. Mostly the goal is handling things like pairing socket.io session ids with user ids, maintaing state on reconnects, and being able to easily group any actors on the server.
Any help is very much appreciated.
Thanks.
Share Improve this question edited Jun 3, 2011 at 13:42 fancy asked Jun 3, 2011 at 1:44 fancyfancy 51.6k64 gold badges158 silver badges230 bronze badges2 Answers
Reset to default 5I've just uploaded a project which allows you to use your sessions from express in Socket.IO. Maybe this can be of some help to you. https://github./aviddiviner/Socket.IO-sessions
You can install it with npm install socket.io-sessions
. Be sure to check out the README.
If you're new to Node, I would suggest spending some time reading through the express docs on how they handle sessions as well. http://expressjs./guide.html#session-support
Lastly, I've also posted some code snippets here: socket.io and session?
Hope that helps!
If you are using socket.io v1+ you can do it the less hacky way by using middleware. Look at https://github./peerigon/socket.io-session-middleware for a middleware which shares sessions between socket.io, connect, express.