Does anybody know if it is possible to capture something like a resource or connection id using the HTML WebSocket specification so that you can re-use or reopen a connection from a previous page. Use case would be I establish a web socket connection while on one page, then the user navigates to a separate page but I don't want to re-establish a new connection but rather use the previous one. You may be asking 'why let the user completely refresh the page?' and it's a legitimate question but not for this use case :) 开发者_C百科
Thanks.
If you open a new tab in your browser context and the original is still connected you can use for example HTML5 storage to pass messages between tabs. With this approach only the first tab will be connected with server through WebSockets and communication can be stored to local storage. Other tabs would handle storage events and thus they don't need to be connected.
精彩评论