Package net.carcdr.yhocuspocus.websocket
Class WebSocketEndpoint
java.lang.Object
net.carcdr.yhocuspocus.websocket.WebSocketEndpoint
- All Implemented Interfaces:
org.eclipse.jetty.websocket.api.Session.Listener,org.eclipse.jetty.websocket.api.Session.Listener.AutoDemanding
public class WebSocketEndpoint
extends Object
implements org.eclipse.jetty.websocket.api.Session.Listener.AutoDemanding
WebSocket endpoint that bridges Jetty WebSocket with YHocuspocus.
This class implements the Jetty WebSocket Session.Listener
interface and creates a WebSocketTransport for each incoming
connection, integrating it with the YHocuspocus server.
Each WebSocket connection gets its own listener instance, allowing proper session tracking and message routing.
Responsibilities:
- Handle WebSocket connection lifecycle (open/close/error)
- Receive binary messages and forward to YHocuspocus
- Create and manage WebSocketTransport instances
- Maintain connection context
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.websocket.api.Session.Listener
org.eclipse.jetty.websocket.api.Session.Listener.Abstract, org.eclipse.jetty.websocket.api.Session.Listener.AbstractAutoDemanding, org.eclipse.jetty.websocket.api.Session.Listener.AutoDemanding -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketEndpoint(net.carcdr.yhocuspocus.core.YHocuspocus server) Creates a new WebSocket endpoint for a single connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidonWebSocketBinary(ByteBuffer payload, org.eclipse.jetty.websocket.api.Callback callback) voidonWebSocketClose(int statusCode, String reason) voidonWebSocketError(Throwable cause) voidonWebSocketOpen(org.eclipse.jetty.websocket.api.Session session) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jetty.websocket.api.Session.Listener
onWebSocketClose, onWebSocketFrame, onWebSocketPartialBinary, onWebSocketPartialText, onWebSocketPing, onWebSocketPong, onWebSocketText
-
Constructor Details
-
WebSocketEndpoint
public WebSocketEndpoint(net.carcdr.yhocuspocus.core.YHocuspocus server) Creates a new WebSocket endpoint for a single connection.- Parameters:
server- the YHocuspocus server instance (must not be null)- Throws:
IllegalArgumentException- if server is null
-
-
Method Details
-
onWebSocketOpen
public void onWebSocketOpen(org.eclipse.jetty.websocket.api.Session session) - Specified by:
onWebSocketOpenin interfaceorg.eclipse.jetty.websocket.api.Session.Listener
-
onWebSocketBinary
public void onWebSocketBinary(ByteBuffer payload, org.eclipse.jetty.websocket.api.Callback callback) - Specified by:
onWebSocketBinaryin interfaceorg.eclipse.jetty.websocket.api.Session.Listener
-
onWebSocketClose
- Specified by:
onWebSocketClosein interfaceorg.eclipse.jetty.websocket.api.Session.Listener
-
onWebSocketError
- Specified by:
onWebSocketErrorin interfaceorg.eclipse.jetty.websocket.api.Session.Listener
-