RpcWebSocketSession

class RpcWebSocketSession(loggerFactory: Logger.Factory, client: HttpClient, node: ClusterNode)

Maintains a WebSocket connection to a remote node and provides mechanisms for sending and handling communication in a clustered environment.

This class is responsible for establishing a WebSocket session with a specified ClusterNode using the provided HTTP client. It includes automatic reconnection logic in case of disconnection and ensures reliable message delivery by retrying operations when failures occur.

Parameters

loggerFactory

Factory for creating a logger instance for this class to enable logging.

client

HTTP client used to manage the WebSocket connections.

node

The cluster node representing the target WebSocket endpoint.

Constructors

Link copied to clipboard
constructor(loggerFactory: Logger.Factory, client: HttpClient, node: ClusterNode)

Initializes the WebSocket session for the given ClusterNode. The connection is established asynchronously upon instantiation.

Functions

Link copied to clipboard
suspend fun close()

Closes the current WebSocket session and marks the session as closed.

Link copied to clipboard
suspend fun send(payload: ByteArray)

Sends a binary payload to the connected WebSocket session with retry logic.