Trait victorem::Game

source ·
pub trait Game {
    fn handle_command(
        &mut self,
        delta_time: Duration,
        commands: Vec<Vec<u8>>,
        from: SocketAddr
    ) -> ContinueRunning; fn draw(&mut self, delta_time: Duration) -> Vec<u8>; fn allow_connect(&mut self, _from: &SocketAddr) -> bool { ... } fn handle_server_event(&mut self, _event: ServerEvent) -> ContinueRunning { ... } fn add_client(&mut self) -> Option<SocketAddr> { ... } fn remove_client(&mut self) -> Option<SocketAddr> { ... } }
Expand description

Game to use with server must implement this trait

Required Methods

delta_time: time elapsed from last call command: ordered commands commands from server from: Address of command sender returns bool value indicating should server continue running if false stops server called only when new commands come to server

gets new state to send to client delta_time: time elapsed throw last call returns bytes with new game state for client called once in about 30 milliseconds sends state only to clients connected to server

Provided Methods

allow client with this IP Address work with server if false server don’t send new state to this client usually don’t implement this method. Use default implementation

Handles events from server returns bool value if returns false stops server usually don’t implement this method. Use default implementation

Client to add to recv state from serve if returns not None then servers on draw sends new state to this client if client with this IP Address already connected then nothing happens usually don’t implement this method. Use default implementation

Disconnect this client from server and don’t send new state to them

Implementors