[−][src]Struct anachro_server::Broker
The Broker Interface
This is the primary interface for devices acting as a broker.
Currently the max capacity is fixed with a maximum of 8 clients connected. Each Client may subscribe up to 8 topics. Each Client may register up to 8 shortcodes.
In the future, these limits may be configurable.
As a note, the Broker currently creates a sizable object, due to the fixed upper limits
Implementations
impl Broker
[src]
pub fn new() -> Self
[src]
Create a new broker with no clients attached
pub fn register_client(&mut self, id: &Uuid) -> Result<(), ServerError>
[src]
Register a client to the broker
This can be done dynamically, e.g. when a client connects for the first time, e.g. a TCP session is established, or the first packet is received, or can be done ahead-of-time, e.g. when communicating with a fixed set of wired devices.
Clients must be registered before messages from them can be processed.
If an already-registered client is re-registered, they will be reset to an initial connection state, dropping all subscriptions or shortcodes.
pub fn remove_client(&mut self, id: &Uuid) -> Result<(), ServerError>
[src]
Remove a client from the broker
This could be necessary if the connection to a client breaks or times out Once removed, no further messages to or from this client will be processed
pub fn reset_client(&mut self, id: &Uuid) -> Result<(), ServerError>
[src]
Reset a client registered with the broker, without removing it
This could be necessary if the connection to a client breaks or times out.
pub fn process_msg<'a, 'b: 'a>(
&'b mut self,
req: &'a Request<'a>
) -> Result<Vec<Response<'a>, U8>, ServerError>
[src]
&'b mut self,
req: &'a Request<'a>
) -> Result<Vec<Response<'a>, U8>, ServerError>
Process a single message from a client
A message from a client will be processed. If processing this message generates responses that need to be sent (e.g. a publish occurs and subscribed clients should be notified, or if the broker is responding to a request from the client), they will be returned, and the messages should be sent to the appropriate clients.
Requests and Responses are addressed by the Uuid registered for each client
NOTE: If an error occurs, you probably should send a RESET_MESSAGE
to
that client to force them to reconnect. You may also want to remove_client
or reset_client
, depending on the situation. This will hopefully be handled
automatically in the future.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,