Trait z4_engine::Handler

source ·
pub trait Handler: Send + Sized + 'static {
    type Param: Param;

    // Required methods
    fn create<'life0, 'async_trait>(
        peers: &'life0 [(Address, PeerId, [u8; 32])],
        params: Vec<u8>,
        rid: RoomId,
        seed: [u8; 32],
    ) -> Pin<Box<dyn Future<Output = (Self, Tasks<Self>)> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        player: PeerId,
        method: &'life1 str,
        param: Self::Param,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn accept<'life0, 'async_trait>(
        _peers: &'life0 [(Address, PeerId, [u8; 32])],
    ) -> Pin<Box<dyn Future<Output = Vec<u8>> + Send + 'async_trait>>
       where 'life0: 'async_trait { ... }
    fn online<'life0, 'async_trait>(
        &'life0 mut self,
        _player: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn offline<'life0, 'async_trait>(
        &'life0 mut self,
        _player: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Handle message received from players

Required Associated Types§

Required Methods§

source

fn create<'life0, 'async_trait>( peers: &'life0 [(Address, PeerId, [u8; 32])], params: Vec<u8>, rid: RoomId, seed: [u8; 32], ) -> Pin<Box<dyn Future<Output = (Self, Tasks<Self>)> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

create new room scan from chain

source

fn handle<'life0, 'life1, 'async_trait>( &'life0 mut self, player: PeerId, method: &'life1 str, param: Self::Param, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

handle message in a room

Provided Methods§

source

fn accept<'life0, 'async_trait>( _peers: &'life0 [(Address, PeerId, [u8; 32])], ) -> Pin<Box<dyn Future<Output = Vec<u8>> + Send + 'async_trait>>
where 'life0: 'async_trait,

accept params when submit to chain

source

fn online<'life0, 'async_trait>( &'life0 mut self, _player: PeerId, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

when player online

source

fn offline<'life0, 'async_trait>( &'life0 mut self, _player: PeerId, ) -> Pin<Box<dyn Future<Output = Result<HandleResult<Self::Param>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

when player offline

Object Safety§

This trait is not object safe.

Implementors§