pub struct OctopipesClient { /* private fields */ }
Expand description
§OctopipesClient
OctopipesClient
is a container for an Octopipes Client
Implementations§
Source§impl OctopipesClient
impl OctopipesClient
Sourcepub fn new(
client_id: String,
cap_pipe: String,
version: OctopipesProtocolVersion,
) -> OctopipesClient
pub fn new( client_id: String, cap_pipe: String, version: OctopipesProtocolVersion, ) -> OctopipesClient
§OctopipesClient Constructor
new
is constructor for OctopipesClient. OctopipesClient is actually a wrapper for a Client
Sourcepub fn loop_start(&mut self) -> Result<(), OctopipesError>
pub fn loop_start(&mut self) -> Result<(), OctopipesError>
§loop_start
loop_start
starts the client loop thread which checks if new messages are available
Sourcepub fn loop_stop(&mut self) -> Result<(), OctopipesError>
pub fn loop_stop(&mut self) -> Result<(), OctopipesError>
§loop_stop
loop_stop
stops the client loop thread
Sourcepub fn subscribe(
&mut self,
subscription_list: &Vec<String>,
) -> Result<OctopipesCapError, OctopipesError>
pub fn subscribe( &mut self, subscription_list: &Vec<String>, ) -> Result<OctopipesCapError, OctopipesError>
§subscribe
subscribe
subscribe to Octopipes server; the client will subscribe to the groups described in the subscription_list
Sourcepub fn unsubscribe(&mut self) -> Result<(), OctopipesError>
pub fn unsubscribe(&mut self) -> Result<(), OctopipesError>
§unsubscribe
unsubscribe
unsubscribe from Octopipes server; if thread is running it will be stopped
Sourcepub fn send(&self, remote: &String, data: Vec<u8>) -> Result<(), OctopipesError>
pub fn send(&self, remote: &String, data: Vec<u8>) -> Result<(), OctopipesError>
§send
send
sends a message to a certain remote
Sourcepub fn send_ex(
&self,
remote: &String,
data: Vec<u8>,
ttl: u8,
options: OctopipesOptions,
) -> Result<(), OctopipesError>
pub fn send_ex( &self, remote: &String, data: Vec<u8>, ttl: u8, options: OctopipesOptions, ) -> Result<(), OctopipesError>
§send_ex
send_ex
sends a message to a certain remote with extended options
Sourcepub fn get_next_message(
&self,
) -> Result<Option<OctopipesMessage>, OctopipesError>
pub fn get_next_message( &self, ) -> Result<Option<OctopipesMessage>, OctopipesError>
§get_next_message
get_next_message
Gets the next available message on the receiver
If a message is available Ok(message) is returned
If no message is available Ok(None) is returned
If there was an error while reading inbox, Err(OctopipesError) is returned
Sourcepub fn get_all_message(&self) -> Result<Vec<OctopipesMessage>, OctopipesError>
pub fn get_all_message(&self) -> Result<Vec<OctopipesMessage>, OctopipesError>
§get_all_message
get_all_message
Gets all the available messages on the receiver
If there was no error while reading the inbox a vector with all the messages is returned (could have length 0)
If there was an error while reading inbox, Err(OctopipesError) is returned
Sourcepub fn set_on_received_callback(
&mut self,
callback: fn(Result<&OctopipesMessage, &OctopipesError>),
)
pub fn set_on_received_callback( &mut self, callback: fn(Result<&OctopipesMessage, &OctopipesError>), )
§set_on_received_callback
set_on_received_callback
sets the function to call on message received
Sourcepub fn set_on_sent_callback(&mut self, callback: fn(&OctopipesMessage))
pub fn set_on_sent_callback(&mut self, callback: fn(&OctopipesMessage))
§set_on_sent_callbacl
set_on_sent_callbacl
sets the function to call when a message is sent
Sourcepub fn set_on_subscribed(&mut self, callback: fn())
pub fn set_on_subscribed(&mut self, callback: fn())
§set_on_subscribed
set_on_subscribed
sets the function to call on a successful subscription to the Octopipes Server
Sourcepub fn set_on_unsubscribed(&mut self, callback: fn())
pub fn set_on_unsubscribed(&mut self, callback: fn())
§set_on_unsubscribed
set_on_unsubscribed
sets the function to call on a successful unsubscription from Octopipes server