WebsocketClientCallback

Trait WebsocketClientCallback 

Source
pub trait WebsocketClientCallback: Sync + Send {
    // Required methods
    fn connected(&self) -> bool;
    fn disconnected(&self);
    fn error(&self, msg: &str);
    fn read(&self, data: &[u8]) -> bool;
}

Required Methods§

Source

fn connected(&self) -> bool

Receive a notification that the websocket connection has been connected successfully.

Return false if you would like to terminate the connection early.

Source

fn disconnected(&self)

Receive a notification that the websocket connection has been terminated.

For implementations, you must call this at the end of the websocket connection lifecycle even if you notify the client of an error.

Source

fn error(&self, msg: &str)

Receive an error from the websocket connection.

For implementations, you typically write the data to an interior mutable buffer on the instance.

Source

fn read(&self, data: &[u8]) -> bool

Receive data from the websocket connection.

For implementations, you typically write the data to an interior mutable buffer on the instance.

Implementors§