pub trait ServerHandler: Send {
    type Request;
    type Response;

    // Required method
    fn on_request<'life0, 'async_trait>(
        &'life0 self,
        ctx: RequestCtx<Self::Request, Self::Response>
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn on_connect<'life0, 'async_trait>(
        &'life0 self,
        id: ConnectionId
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn on_disconnect<'life0, 'async_trait>(
        &'life0 self,
        id: ConnectionId
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Interface for a handler that receives connections and requests

Required Associated Types§

source

type Request

Type of data received by the server

source

type Response

Type of data sent back by the server

Required Methods§

source

fn on_request<'life0, 'async_trait>( &'life0 self, ctx: RequestCtx<Self::Request, Self::Response> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Invoked upon receiving a request from a client. The server should process this request, which can be found in ctx, and send one or more replies in response.

Provided Methods§

source

fn on_connect<'life0, 'async_trait>( &'life0 self, id: ConnectionId ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait,

Invoked upon a new connection becoming established.

source

fn on_disconnect<'life0, 'async_trait>( &'life0 self, id: ConnectionId ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait,

Invoked upon an existing connection getting dropped.

Implementors§