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§
sourcefn ggrs_socket(&self) -> Socket
fn ggrs_socket(&self) -> Socket
Get a GGRS socket from this network socket.
sourcefn send_reliable(&self, target: SocketTarget, message: &[u8])
fn send_reliable(&self, target: SocketTarget, message: &[u8])
Send a reliable message to the given SocketTarget
.
sourcefn recv_reliable(&self) -> Vec<(u32, Vec<u8>)>
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.
sourcefn player_idx(&self) -> u32
fn player_idx(&self) -> u32
Get the player index of the local player.
sourcefn player_count(&self) -> u32
fn player_count(&self) -> u32
Get the player count for this network match.
sourcefn increment_match_id(&mut self)
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.