title: Websocket keep track of connections in Spring
body: <p>Today I've searched a couple of hours for an implementation or tutorial in how to keep track of websocket connections in Spring. </p>
  
  <p>I've done the (very good) Spring tutorial about websockets and STOMP. 
  link <a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="noreferrer">here</a></p>
  
  <p>So what's my setup, I have an Ionic Hybrid app with an Spring backend and I want to send a notification to the client whenever a new notification-event arises in the backend. All this code is already implemented and the connection works, but right now there is no way to specify where the notifications need to go to.</p>
  
  <p>There is no tutorial or explanation on this matter that follows the structure in the Spring tutorial (at least not after 5 hours of research) and I am a little overwhelmed by all the information about websockets and security on the web. (I've been learning about websockets for just 2 days)</p>
  
  <p>So for all that been before me and will come after me, I think it can be very usefull to have a compact and lightweight answer following the structure taught by the Spring Tutorial.</p>
  
  <p>I've found <a href="https://stackoverflow.com/questions/37854062/authentication-model-for-spring-websocket-sockjs-and-sending-messages-on-per-u">this unanswered question</a> on StackOverflow about the same problems as I have, so I'm sure this questions will prove it's worth.</p>
  
  <p>TL;DR</p>
  
  <p>How to implement a list in the backend that keeps track of the connections based on the <a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="noreferrer">Spring WebSocket Tutorial</a>?</p>
  
  <p>How to send data from the client to the backend when the connection is established? (for example a userid or token)</p>