Struct client::GameplaySocket
source · [−]pub struct GameplaySocket {
pub debug_max_message_length: usize,
/* private fields */
}
Expand description
Wrapper around UDP and TCP sockets for communicating with the game server.
Implementation details
TCP is only used for the initial login, which is encrypted with TLS. The root certificate is built into the client. The following gameplay updates are sent over UDP, encrypted with ChaCha20-Poly1305, using a secret shared during the login process. The UDP messages are processed with MessageOrderer to make sure they arrive, and that are processed in order.
Fields
debug_max_message_length: usize
Implementations
sourceimpl GameplaySocket
impl GameplaySocket
sourcepub fn new() -> Result<GameplaySocket>
pub fn new() -> Result<GameplaySocket>
Connects to the game’s login servers and sets up the communication channel. GameplaySocket::transport should be called periodically (many times a second) afterwards, to transport sent messages, as well as keepalive messages.
sourcepub fn disconnected(&self) -> bool
pub fn disconnected(&self) -> bool
Returns true after it’s been common::protocol::DISCONNECT_THRESHOLD since the last packet from the server.
sourcepub fn send(&mut self, action: ClientAction)
pub fn send(&mut self, action: ClientAction)
Queues the ClientAction for sending during the next GameplaySocket::transport.
sourcepub fn recv(&mut self) -> Option<ServerAction>
pub fn recv(&mut self) -> Option<ServerAction>
Returns any ServerActions received during previously called GameplaySocket::transports.
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