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
impl RUMServerHandle
Sourcepub fn default(port: u16) -> RUMResult<RUMServerHandle>
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.
Sourcepub fn default_local(port: u16) -> RUMResult<RUMServerHandle>
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.
Sourcepub fn new(ip: &str, port: u16, threads: usize) -> RUMResult<RUMServerHandle>
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.
Sourcepub fn start(&mut self, blocking: bool) -> RUMResult<()>
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.
Sourcepub fn stop(&mut self) -> RUMResult<RUMString>
pub fn stop(&mut self) -> RUMResult<RUMString>
Sync API method for signalling the server to stop operations.
Sourcepub fn send(
&mut self,
client_id: &RUMString,
msg: &RUMNetMessage,
) -> RUMResult<()>
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.
Sourcepub fn receive(&mut self, client_id: &RUMString) -> RUMResult<RUMNetMessage>
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
Sourcepub fn get_clients(&self) -> ClientList
pub fn get_clients(&self) -> ClientList
Sync API method for obtaining the client list of the server.
Sourcepub fn get_client_ids(&self) -> ClientIDList
pub fn get_client_ids(&self) -> ClientIDList
Sync API method for obtaining the client list of the server.
Sourcepub fn gc_clients(&self) -> RUMResult<()>
pub fn gc_clients(&self) -> RUMResult<()>
Garbage Collection API method for dropping clients flagged as disconnected.
Sourcepub fn get_address_info(&self) -> Option<RUMString>
pub fn get_address_info(&self) -> Option<RUMString>
Get the Address:Port info for this socket.