Skip to main content

SocketTransport

Trait SocketTransport 

Source
pub trait SocketTransport:
    Send
    + Sync
    + 'static {
    // Required methods
    fn set_addr(&self, addr: Option<String>);
    fn close(&self);
    fn intended_connection_state(
        &self,
    ) -> Cell<SocketConnectionStatus, CellImmutable>;
    fn actual_connection_state(
        &self,
    ) -> Cell<SocketConnectionStatus, CellImmutable>;
    fn send(&self, frame: WsFrame) -> Result<(), String>;
    fn read_rx(&self) -> Receiver<WsFrame>;
}
Expand description

Abstraction over a WebSocket connection with auto-reconnect behaviour.

Implemented by AutoReconnectSocket (native) and WasmSocket (browser). Object-safe: uses callback-based subscriptions instead of channel returns.

Required Methods§

Source

fn set_addr(&self, addr: Option<String>)

Set the remote address. None disconnects.

Source

fn close(&self)

Close the connection and stop reconnection attempts.

Source

fn intended_connection_state( &self, ) -> Cell<SocketConnectionStatus, CellImmutable>

Intended connection state requested by the caller.

Source

fn actual_connection_state(&self) -> Cell<SocketConnectionStatus, CellImmutable>

Actual observed connection state of the transport.

Source

fn send(&self, frame: WsFrame) -> Result<(), String>

Send a frame to the remote end.

Source

fn read_rx(&self) -> Receiver<WsFrame>

Read stream of incoming websocket frames.

Implementors§