Package net.carcdr.yhocuspocus.core
Class ClientConnection
java.lang.Object
net.carcdr.yhocuspocus.core.ClientConnection
- All Implemented Interfaces:
AutoCloseable,ReceiveListener
Manages a client transport connection.
Handles authentication, message routing, and document multiplexing over a single transport connection. Transport-agnostic design allows use with WebSocket, HTTP, or other protocols.
Key responsibilities:
- Authentication flow per document
- Message queueing during authentication
- Document multiplexing (multiple documents per connection)
- Clean shutdown and resource cleanup
Note: Keepalive/ping mechanisms are handled by the transport layer (e.g., WebSocket ping/pong) to maintain transport-agnostic design.
-
Method Summary
-
Method Details
-
onMessage
public void onMessage(byte[] data) Called by the transport when a binary message is received.Implements
ReceiveListener.onMessage(byte[]).- Specified by:
onMessagein interfaceReceiveListener- Parameters:
data- the raw message data
-
send
public void send(byte[] message) Sends a message via transport.- Parameters:
message- the message bytes
-
close
Closes this connection.- Parameters:
code- close codereason- close reason
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getConnectionId
Gets the connection ID.- Returns:
- connection ID
-
getContext
Gets the connection context.- Returns:
- mutable context map
-
getTransport
Gets the transport.- Returns:
- transport instance
-