RUMServerHandle

Struct RUMServerHandle 

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

Handle struct containing a reference to the global Tokio runtime and an instance of SafeServer. This handle allows sync codebases to interact with the async primitives built on top of Tokio. Specifically, this handle allows wrapping of the async bind, send, receive, and start methods implemented in RUMServer. In addition, this handle allows spinning a server in a fully non-blocking manner. Meaning, you can call start, which will immediately return after queueing the task in the tokio queue. You can then query the server for incoming data or submit your own data while the server is operating in the background. The server can be handling incoming data at the “same” time you are trying to queue your own message.

Implementations§

Source§

impl RUMServerHandle

Source

pub fn default(port: u16) -> RUMResult<RUMServerHandle>

Constructs a RUMServerHandle using the detected number of parallel units/threads on this machine. This method automatically binds to IP 0.0.0.0. Meaning, your server may become visible to the outside world.

Source

pub fn default_local(port: u16) -> RUMResult<RUMServerHandle>

Constructs a RUMServerHandle using the detected number of parallel units/threads on this machine. This method automatically binds to localhost. Meaning, your server remains private in your machine.

Source

pub fn new(ip: &str, port: u16, threads: usize) -> RUMResult<RUMServerHandle>

General purpose constructor for RUMServerHandle. It takes an ip and port and binds it. You can also control how many threads are spawned under the hood for this server handle.

Source

pub fn start(&mut self, blocking: bool) -> RUMResult<()>

Starts the main processing loop for the server. This processing loop listens for new clients in a non-blocking manner and checks for incoming data and data that must be shipped to clients. You can start the server in a blocking and non_blocking manner.

Source

pub fn stop(&mut self) -> RUMResult<RUMString>

Sync API method for signalling the server to stop operations.

Source

pub fn send( &mut self, client_id: &RUMString, msg: &RUMNetMessage, ) -> RUMResult<()>

Sync API method for queueing a message to send a client on the server.

Source

pub fn receive(&mut self, client_id: &RUMString) -> RUMResult<RUMNetMessage>

Sync API method for obtaining a single message from the server’s incoming queue. Returns the next available RUMNetMessage

Source

pub fn get_clients(&self) -> ClientList

Sync API method for obtaining the client list of the server.

Source

pub fn get_client_ids(&self) -> ClientIDList

Sync API method for obtaining the client list of the server.

Source

pub fn gc_clients(&self) -> RUMResult<()>

Garbage Collection API method for dropping clients flagged as disconnected.

Source

pub fn get_address_info(&self) -> Option<RUMString>

Get the Address:Port info for this socket.

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.