最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - An explanation of session support using Express and Socket.IO? - Stack Overflow

programmeradmin2浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

I'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.

发布评论

评论列表(0)

  1. 暂无评论