Skip to content

how to capture connection event in my webSocket server with Spring 4?

I did a simple web socket communication with spring 4,STOMP and sock.js, following this and this

well, I want to know if is possible capture connection events like when a new client was connected to my server or when a client was disconnected, is that possible in Spring 4.0.0?


This an be done with a connection handshake interceptor (HttpSessionHandshakeInterceptor), quoting the documentation:

The easiest way to customize the initial HTTP WebSocket handshake request is through a HandshakeInterceptor, which exposes “before” and “after” the handshake methods.