Class SpringWebSocketTransport
java.lang.Object
net.carcdr.yhocuspocus.spring.websocket.SpringWebSocketTransport
- All Implemented Interfaces:
AutoCloseable,net.carcdr.yhocuspocus.transport.Transport
public class SpringWebSocketTransport
extends Object
implements net.carcdr.yhocuspocus.transport.Transport
Spring WebSocket transport implementation.
This class adapts a Spring WebSocketSession to the
Transport interface, allowing YHocuspocus to work with
Spring WebSocket connections.
Thread-safe implementation that handles:
- Binary message transmission
- Connection state tracking
- Graceful closure with WebSocket close codes
- Remote address extraction
- Since:
- 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionSpringWebSocketTransport(org.springframework.web.socket.WebSocketSession session) Creates a new Spring WebSocket transport from a session. -
Method Summary
Modifier and TypeMethodDescriptionvoidorg.springframework.web.socket.WebSocketSessionGets the underlying Spring WebSocket session.booleanisOpen()send(byte[] message) voidsetReceiveListener(net.carcdr.yhocuspocus.transport.ReceiveListener listener) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.carcdr.yhocuspocus.transport.Transport
close
-
Constructor Details
-
SpringWebSocketTransport
public SpringWebSocketTransport(org.springframework.web.socket.WebSocketSession session) Creates a new Spring WebSocket transport from a session.- Parameters:
session- the WebSocket session (must not be null)- Throws:
IllegalArgumentException- if session is null
-
-
Method Details
-
send
- Specified by:
sendin interfacenet.carcdr.yhocuspocus.transport.Transport
-
getConnectionId
- Specified by:
getConnectionIdin interfacenet.carcdr.yhocuspocus.transport.Transport
-
close
- Specified by:
closein interfacenet.carcdr.yhocuspocus.transport.Transport
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfacenet.carcdr.yhocuspocus.transport.Transport
-
getRemoteAddress
- Specified by:
getRemoteAddressin interfacenet.carcdr.yhocuspocus.transport.Transport
-
setReceiveListener
public void setReceiveListener(net.carcdr.yhocuspocus.transport.ReceiveListener listener) - Specified by:
setReceiveListenerin interfacenet.carcdr.yhocuspocus.transport.Transport
-
getSession
public org.springframework.web.socket.WebSocketSession getSession()Gets the underlying Spring WebSocket session.- Returns:
- the WebSocket session
-