Struct server::gameplay_socket::GameplaySocket
source · [−]pub struct GameplaySocket {
socket: UdpSocket,
peer_refresh_times: HashMap<PeerIdentifier, Instant>,
peer_addrs: HashMap<PeerIdentifier, SocketAddr>,
peer_queues: HashMap<PeerIdentifier, MessageOrderer<ServerAction, ClientAction>>,
}
Expand description
Sends effects and receives actions over UDP.
Fields
socket: UdpSocket
peer_refresh_times: HashMap<PeerIdentifier, Instant>
peer_addrs: HashMap<PeerIdentifier, SocketAddr>
peer_queues: HashMap<PeerIdentifier, MessageOrderer<ServerAction, ClientAction>>
Implementations
sourceimpl GameplaySocket
impl GameplaySocket
sourcepub fn new() -> Result<GameplaySocket>
pub fn new() -> Result<GameplaySocket>
Binds a UdpSocket to 0.0.0.0:7812
to start listening for messages
and sets up initial state.
sourcepub fn add_peer(&mut self, peer_id: PeerIdentifier, encryption_key: [u8; 32])
pub fn add_peer(&mut self, peer_id: PeerIdentifier, encryption_key: [u8; 32])
Used by the LoginServer, adds a new peer identifier to listen for, and their associated encryption key.
sourcepub fn recv_actions(&mut self) -> Option<(PeerIdentifier, ClientAction)>
pub fn recv_actions(&mut self) -> Option<(PeerIdentifier, ClientAction)>
Returns queued messages as long as there are any. These are queued up by GameplaySocket::transport.
sourcepub fn refresh(&mut self) -> Vec<PeerIdentifier>
pub fn refresh(&mut self) -> Vec<PeerIdentifier>
Disconnects clients that haven’t been refreshed in a while, returns all of the current peers.
sourcepub fn send_action(&mut self, peer: PeerIdentifier, action: ServerAction)
pub fn send_action(&mut self, peer: PeerIdentifier, action: ServerAction)
Queues up the action to the peer, for sending during the next GameplaySocket::transport.
Auto Trait Implementations
impl RefUnwindSafe for GameplaySocket
impl Send for GameplaySocket
impl Sync for GameplaySocket
impl Unpin for GameplaySocket
impl UnwindSafe for GameplaySocket
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more