title: Spring websocket: how intercept the send event through the AbstractSubProtocolEvent hierarchy?
body: <p>About Spring websocket about intercept <code>Stomp</code> events one approach is extends from the <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/messaging/support/ChannelInterceptorAdapter.html" rel="nofollow noreferrer">ChannelInterceptorAdapter</a> class</p>
  
  <p>It works how is expected. More details here:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/50419131/spring-websocket-how-convert-easily-the-messages-payload-to-pojo-in-channel">Spring websocket: how convert easily the Message's payload to POJO in ChannelInterceptorAdapter</a></li>
  </ul>
  
  <p>Now, according with this tutorial:</p>
  
  <ul>
  <li><a href="http://www.sergialmar.com/2014/03/detect-websocket-connects-and-disconnects-in-spring-4/" rel="nofollow noreferrer">Detecting WebSocket Connects and Disconnects in Spring 4</a></li>
  </ul>
  
  <p>the approach mentioned above is covered <em>and</em> other approach is work around with <code>ApplicationEvents</code>, it through with:</p>
  
  <ul>
  <li><a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/socket/messaging/SessionConnectEvent.html" rel="nofollow noreferrer">SessionConnectEvent</a></li>
  <li><a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/socket/messaging/SessionConnectedEvent.html" rel="nofollow noreferrer">SessionConnectedEvent</a></li>
  <li><a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/socket/messaging/SessionDisconnectEvent.html" rel="nofollow noreferrer">SessionDisconnectEvent</a> </li>
  </ul>
  
  <p>These classes extends from:</p>
  
  <ul>
  <li><a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/socket/messaging/AbstractSubProtocolEvent.html" rel="nofollow noreferrer">AbstractSubProtocolEvent</a></li>
  </ul>
  
  <p>And exists two subclasses more:</p>
  
  <ul>
  <li><a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/socket/messaging/SessionSubscribeEvent.html" rel="nofollow noreferrer">SessionSubscribeEvent</a></li>
  <li><a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/socket/messaging/SessionUnsubscribeEvent.html" rel="nofollow noreferrer">SessionUnsubscribeEvent</a></li>
  </ul>
  
  <p>This list is confirmed in (by the same author):</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/21781667/how-to-capture-connection-event-in-my-websocket-server-with-spring-4/49754626#49754626">how to capture connection event in my webSocket server with Spring 4?</a></li>
  </ul>
  
  <p>The names are by themselves obvious to know what each one does, but just curious </p>
  
  <ul>
  <li>Why there is no none for the <code>send</code> event? </li>
  </ul>
  
  <p>It to react from:</p>
  
  <pre><code>stompClient.send('/app/ws/something', 
                   {}, 
                   JSON.stringify({'content': $('#content').val()})
  </code></pre>
  
  <p>For this <code>send</code> event "seems" mandatory work with the <code>ChannelInterceptorAdapter</code> through the <code>postSend(Message&lt;?&gt; message, MessageChannel channel, boolean sent)</code> method yet</p>