1

I have a multipage website (atm, that also means sockets open and close with every http request), and after the user logs in, i need to somehow link the socket to his user _id (mongodb), in order to be able to send private messages in realtime, and update other parts of the website just for that user.

Currently when a user logs in, his details are stored in the express session variables. Is there an easy way to read the express session with socket? I have looked on other questions on this topic, but couldnt get that to work.

Would there be any other suggestions? Of course i could make the website a single page, which would prevent sockets from opening and closing so often, but that still doesnt solve the identification of every socket.

Thanks!

4

1 回答 1

0

你可以试试看一下comet,它允许长寿命的HTTP。

请参阅http://www.ibm.com/developerworks/library/wa-cometjava/

于 2013-08-22T08:33:38.437 回答