pub struct Session { /* private fields */ }Expand description
One independent, reliable EQ UDP session. Sequence numbers and CRC state belong to this socket and are discarded on world/zone transitions.
Implementations§
Source§impl Session
impl Session
Sourcepub fn local_address(&self) -> Result<SocketAddr, Error>
pub fn local_address(&self) -> Result<SocketAddr, Error>
Return the local UDP address selected for this session.
§Errors
Returns an error when the operating system cannot read the socket address.
Sourcepub fn last_received_seconds(&self) -> u64
pub fn last_received_seconds(&self) -> u64
Return whole seconds since the last valid server datagram.
Sourcepub fn connect(
address: SocketAddr,
echo_response: bool,
) -> Result<Session, Error>
pub fn connect( address: SocketAddr, echo_response: bool, ) -> Result<Session, Error>
Negotiate a new reliable EQ UDP session with the remote endpoint.
§Errors
Returns an error when socket setup, negotiation, or validation fails.
Sourcepub fn connect_cancellable(
address: SocketAddr,
echo_response: bool,
stop: &Atomic<bool>,
) -> Result<Session, Error>
pub fn connect_cancellable( address: SocketAddr, echo_response: bool, stop: &Atomic<bool>, ) -> Result<Session, Error>
Negotiate a session while allowing its owner to cancel network waits.
§Errors
Returns an error on cancellation, timeout, socket failure, or an unsupported negotiation response.
Sourcepub fn send(&mut self, opcode: u16, body: &[u8]) -> Result<(), Error>
pub fn send(&mut self, opcode: u16, body: &[u8]) -> Result<(), Error>
Send one reliable application packet, fragmenting it when necessary.
§Errors
Returns an error when the session is closed, a size limit is exceeded, or the UDP socket cannot send a packet.
Sourcepub fn send_unreliable(&self, opcode: u16, body: &[u8]) -> Result<(), Error>
pub fn send_unreliable(&self, opcode: u16, body: &[u8]) -> Result<(), Error>
Send an unsequenced application packet, used for position heartbeats.
§Errors
Returns an error for an unsupported opcode, an oversized datagram, or a UDP socket failure.