Class SpringWebSocketHandler
java.lang.Object
org.springframework.web.socket.handler.AbstractWebSocketHandler
org.springframework.web.socket.handler.BinaryWebSocketHandler
net.carcdr.yhocuspocus.spring.websocket.SpringWebSocketHandler
- All Implemented Interfaces:
org.springframework.web.socket.WebSocketHandler
public class SpringWebSocketHandler
extends org.springframework.web.socket.handler.BinaryWebSocketHandler
Spring WebSocket handler for YHocuspocus connections.
This class extends Spring's BinaryWebSocketHandler and creates
a SpringWebSocketTransport for each incoming connection, integrating
it with the YHocuspocus server.
Responsibilities:
- Handle WebSocket connection lifecycle (open/close/error)
- Receive binary messages and forward to YHocuspocus
- Create and manage SpringWebSocketTransport instances
- Maintain connection context from session attributes
- Since:
- 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionSpringWebSocketHandler(net.carcdr.yhocuspocus.core.YHocuspocus server) Creates a new Spring WebSocket handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterConnectionClosed(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus status) voidafterConnectionEstablished(org.springframework.web.socket.WebSocketSession session) intGets the number of active connections.net.carcdr.yhocuspocus.core.YHocuspocusGets the YHocuspocus server instance.protected voidhandleBinaryMessage(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.BinaryMessage message) voidhandleTransportError(org.springframework.web.socket.WebSocketSession session, Throwable exception) Methods inherited from class org.springframework.web.socket.handler.BinaryWebSocketHandler
handleTextMessageMethods inherited from class org.springframework.web.socket.handler.AbstractWebSocketHandler
handleMessage, handlePongMessage, supportsPartialMessages
-
Constructor Details
-
SpringWebSocketHandler
public SpringWebSocketHandler(net.carcdr.yhocuspocus.core.YHocuspocus server) Creates a new Spring WebSocket handler.- Parameters:
server- the YHocuspocus server instance (must not be null)- Throws:
IllegalArgumentException- if server is null
-
-
Method Details
-
afterConnectionEstablished
public void afterConnectionEstablished(org.springframework.web.socket.WebSocketSession session) throws Exception - Specified by:
afterConnectionEstablishedin interfaceorg.springframework.web.socket.WebSocketHandler- Overrides:
afterConnectionEstablishedin classorg.springframework.web.socket.handler.AbstractWebSocketHandler- Throws:
Exception
-
handleBinaryMessage
protected void handleBinaryMessage(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.BinaryMessage message) - Overrides:
handleBinaryMessagein classorg.springframework.web.socket.handler.AbstractWebSocketHandler
-
afterConnectionClosed
public void afterConnectionClosed(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus status) - Specified by:
afterConnectionClosedin interfaceorg.springframework.web.socket.WebSocketHandler- Overrides:
afterConnectionClosedin classorg.springframework.web.socket.handler.AbstractWebSocketHandler
-
handleTransportError
public void handleTransportError(org.springframework.web.socket.WebSocketSession session, Throwable exception) - Specified by:
handleTransportErrorin interfaceorg.springframework.web.socket.WebSocketHandler- Overrides:
handleTransportErrorin classorg.springframework.web.socket.handler.AbstractWebSocketHandler
-
getConnectionCount
public int getConnectionCount()Gets the number of active connections.- Returns:
- the number of active connections
-
getServer
public net.carcdr.yhocuspocus.core.YHocuspocus getServer()Gets the YHocuspocus server instance.- Returns:
- the server instance
-