title: Tomcat websocket management and identification
body: <p>I am trying to implement a web socket session manager and I have just encountered a road block that I hope someone can assist me with.</p>
  
  <p>Basically a client will initiate a web socket session with my websocket server endpoint and I will take the HTTP request parameters, parse it and subscribe to web service producer endpoint. The Web service will return a response containing a subscription identifier of which will use as a key mapping (along with the HTTP session ID) to add to a java map cache with the session object. The  proceed to send data to my published webservice consumer endpoint. My application will then take the data received from the producer, use the subscription id that comes with each packet and find the right session in the map caches to send the data back to.</p>
  
  <p>Here is my problem.. </p>
  
  <p>I noticed that if the client opens another tab in the browser and sends a second subscription request, it would still be sent with the same HTTP Session ID yet tomcat will still be able to stream the data to the correct tab. This implies that the tomcat websocket implementation has a built in multiplex handling mechanism.</p>
  
  <p>To exclude some unnecessary details unless asked, I want to to also be able identify all the channels that were multiplexed under the same session id. But I can't find any way in the API to identify it. As I need to be able to look up my map caches and remove sessions for tabs that have been closed (which triggers a close method in my web socket endpoint), but I'm not going to be able to do that as there could be many sockets/channels associated with the same HTTP Session ID.</p>