Trait bones_framework::networking::NetworkSocket

source ·
pub trait NetworkSocket: Sync + Send {
    // Required methods
    fn ggrs_socket(&self) -> Socket;
    fn send_reliable(&self, target: SocketTarget, message: &[u8]);
    fn recv_reliable(&self) -> Vec<(u32, Vec<u8>)>;
    fn close(&self);
    fn player_idx(&self) -> u32;
    fn player_count(&self) -> u32;
    fn increment_match_id(&mut self);
}
Expand description

Trait that must be implemented by socket connections establish by matchmakers.

The NetworkMatchSocket resource will contain an instance of this trait and will be used by the game to send network messages after a match has been established.

Required Methods§

source

fn ggrs_socket(&self) -> Socket

Get a GGRS socket from this network socket.

source

fn send_reliable(&self, target: SocketTarget, message: &[u8])

Send a reliable message to the given SocketTarget.

source

fn recv_reliable(&self) -> Vec<(u32, Vec<u8>)>

Receive reliable messages from other players. The usize is the index of the player that sent the message.

source

fn close(&self)

Close the connection.

source

fn player_idx(&self) -> u32

Get the player index of the local player.

source

fn player_count(&self) -> u32

Get the player count for this network match.

source

fn increment_match_id(&mut self)

Increment match id so messages from previous match that are still in flight will be filtered out. Used when starting new session with existing socket.

Implementors§