Skip to main content

TokioSoeServer

Struct TokioSoeServer 

Source
pub struct TokioSoeServer { /* private fields */ }
Expand description

An actor-style SOE server: a SoeMultiplexer driven on its own Tokio task, reachable from any task via a cloneable SoeHandle.

This is the recommended shape for a game server. The driver task owns the UDP socket and all protocol state (sequence numbers, ciphers, reassembly), which is inherently single-owner. Application code interacts with it asynchronously:

  • Obtain a cloneable SoeHandle with handle and share it with per-client game-logic tasks to send data or manage sessions.
  • Receive SocketEvents with recv_event and route them (e.g. fan DataReceived out to the matching per-client task).

Because each server owns one socket and one multiplexer, scaling UDP I/O across cores later is a matter of running several servers — one per SO_REUSEPORT socket — and routing by client address; no change to the core is required.

The driver task runs until the TokioSoeServer and every SoeHandle are dropped, or until the event receiver is dropped.

Implementations§

Source§

impl TokioSoeServer

Source

pub async fn bind( local: SocketAddr, config: SocketConfig, tick_period: Duration, ) -> Result<Self>

Binds a UDP socket to local and spawns the driver loop, ticking every tick_period. A period of 1–10ms is typical.

Source

pub fn local_addr(&self) -> SocketAddr

Returns the local address the server is bound to.

Source

pub fn handle(&self) -> SoeHandle

Returns a cloneable handle for sending commands to the server from any task.

Source

pub async fn recv_event(&mut self) -> Option<SocketEvent<SocketAddr>>

Awaits the next event from the driver loop, or None once the loop has stopped.

Source

pub fn abort(&self)

Aborts the driver task, stopping the server.

Trait Implementations§

Source§

impl Debug for TokioSoeServer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.