I'm trying to create a site that uses websocket++ as its' total backbone, and I've just realized that I might have a dilemma if a user opens multiple tabs/windows.

I'm writing spa style, where all html and most css & js are loaded up front, and whenever a user clicks a link like one of the stack links above, it simply slides away the old div and slides in the new. This is easy with ajax, but anyone who does 100% ajax knows the hell of constant updating.

Websockets and websocket++ makes autoupdating and user tracking easy, but I don't know how to handle a situation where the user doesn't appreciate all of my spa programming and wants another tab/window lol.

If a user opens another tab/window, will websocket++ automatically assign the tab/window another connection_hdl? If so, how can I ensure the user is logged into the new tab/window? If not, how can I separate the user tracking for each tab/window?

有帮助吗?

解决方案

Every connection to a WebSocket++ server will get its own unique connection_hdl. This will happen if you open two WebSocket's from one application or the same application in multiple tabs/windows/computers.

Associating a given connection with a user is a pretty broad question. In short, like with non-websocket methods, you'll need to send along a username/password or session token to the server for each connection. If you want a single sign-on like effect between different tabs/windows you can use the browser's persistent client side storage (cookies, local storage, etc) to store those session tokens.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top