Struct wamp_async::Client [−][src]
Allows interaction as a client with a WAMP server
Implementations
impl<'a> Client<'a>
[src]
pub async fn connect<T: AsRef<str>>(
uri: T,
cfg: Option<ClientConfig>
) -> Result<(Client<'a>, (GenericFuture<'a>, Option<UnboundedReceiver<GenericFuture<'a>>>)), WampError>
[src]
uri: T,
cfg: Option<ClientConfig>
) -> Result<(Client<'a>, (GenericFuture<'a>, Option<UnboundedReceiver<GenericFuture<'a>>>)), WampError>
Connects to a WAMP server using the specified protocol
Note
On success, this function returns :
- Client : Used to interact with the server
- Main event loop Future : This MUST be spawned by the caller (e.g using tokio::spawn())
- RPC event queue : If you register RPC endpoints, you MUST spawn a seperate task to also handle these events
To customize parmeters used for the connection, see the ClientConfig struct
pub async fn join_realm<T: Into<String>>(
&mut self,
realm: T
) -> Result<(), WampError>
[src]
&mut self,
realm: T
) -> Result<(), WampError>
Attempts to join a realm and start a session with the server.
realm
- A name of the WAMP realm
pub async fn join_realm_with_authentication<Realm, AuthenticationId, AuthenticationChallengeHandler, AuthenticationChallengeHandlerResponse>(
&mut self,
realm: Realm,
authentication_methods: Vec<AuthenticationMethod>,
authentication_id: AuthenticationId,
on_challenge_handler: AuthenticationChallengeHandler
) -> Result<(), WampError> where
Realm: Into<String>,
AuthenticationId: Into<String>,
AuthenticationChallengeHandler: Fn(AuthenticationMethod, WampDict) -> AuthenticationChallengeHandlerResponse + Send + Sync + 'a,
AuthenticationChallengeHandlerResponse: Future<Output = Result<AuthenticationChallengeResponse, WampError>> + Send + 'a,
[src]
&mut self,
realm: Realm,
authentication_methods: Vec<AuthenticationMethod>,
authentication_id: AuthenticationId,
on_challenge_handler: AuthenticationChallengeHandler
) -> Result<(), WampError> where
Realm: Into<String>,
AuthenticationId: Into<String>,
AuthenticationChallengeHandler: Fn(AuthenticationMethod, WampDict) -> AuthenticationChallengeHandlerResponse + Send + Sync + 'a,
AuthenticationChallengeHandlerResponse: Future<Output = Result<AuthenticationChallengeResponse, WampError>> + Send + 'a,
Attempts to join a realm and start a session with the server.
realm
- A name of the WAMP realmauthentication_methods
- A set of all the authentication methods the client will supportauthentication_id
- An authentication ID (e.g. username) the client wishes to authenticate as. It is required for non-anynomous authentication methods.on_challenge_handler
- An authentication handler function
client .join_realm_with_authentication( "realm1", vec![wamp_async::AuthenticationMethod::Ticket], "username", |_authentication_method, _extra| async { Ok(wamp_async::AuthenticationChallengeResponse::with_signature( "password".into(), )) }, ) .await?;
pub async fn leave_realm(&mut self) -> Result<(), WampError>
[src]
Leaves the current realm and terminates the session with the server
pub async fn subscribe<T: AsRef<str>>(
&self,
topic: T
) -> Result<(WampId, UnboundedReceiver<(WampId, Option<WampArgs>, Option<WampKwArgs>)>), WampError>
[src]
&self,
topic: T
) -> Result<(WampId, UnboundedReceiver<(WampId, Option<WampArgs>, Option<WampKwArgs>)>), WampError>
Subscribes to events for the specifiec topic
This function returns a subscription ID (required to unsubscribe) and the receive end of a channel for events published on the topic.
pub async fn unsubscribe(&self, sub_id: WampId) -> Result<(), WampError>
[src]
Unsubscribes to a previously subscribed topic
pub async fn publish<T: AsRef<str>>(
&self,
topic: T,
arguments: Option<WampArgs>,
arguments_kw: Option<WampKwArgs>,
acknowledge: bool
) -> Result<Option<WampId>, WampError>
[src]
&self,
topic: T,
arguments: Option<WampArgs>,
arguments_kw: Option<WampKwArgs>,
acknowledge: bool
) -> Result<Option<WampId>, WampError>
Publishes an event on a specific topic
The caller can set acknowledge
to true to receive unique IDs from the server
for each published event.
pub async fn register<T, F, Fut>(
&self,
uri: T,
func_ptr: F
) -> Result<WampId, WampError> where
T: AsRef<str>,
F: Fn(Option<WampArgs>, Option<WampKwArgs>) -> Fut + Send + Sync + 'a,
Fut: Future<Output = Result<(Option<WampArgs>, Option<WampKwArgs>), WampError>> + Send + 'a,
[src]
&self,
uri: T,
func_ptr: F
) -> Result<WampId, WampError> where
T: AsRef<str>,
F: Fn(Option<WampArgs>, Option<WampKwArgs>) -> Fut + Send + Sync + 'a,
Fut: Future<Output = Result<(Option<WampArgs>, Option<WampKwArgs>), WampError>> + Send + 'a,
Register an RPC endpoint. Upon succesful registration, a registration ID is returned (used to unregister) and calls received from the server will generate a future which will be sent on the rpc event channel returned by the call to event_loop()
pub async fn unregister(&self, rpc_id: WampId) -> Result<(), WampError>
[src]
Unregisters an RPC endpoint
pub async fn call<T: AsRef<str>>(
&self,
uri: T,
arguments: Option<WampArgs>,
arguments_kw: Option<WampKwArgs>
) -> Result<(Option<WampArgs>, Option<WampKwArgs>), WampError>
[src]
&self,
uri: T,
arguments: Option<WampArgs>,
arguments_kw: Option<WampKwArgs>
) -> Result<(Option<WampArgs>, Option<WampKwArgs>), WampError>
Calls a registered RPC endpoint on the server
pub fn get_cur_status(&mut self) -> &ClientState
[src]
Returns the current client status
pub fn is_connected(&mut self) -> bool
[src]
Returns whether we are connected to the server or not
pub async fn block_until_disconnect(&mut self) -> &ClientState
[src]
Blocks the caller until the connection with the server is terminated
pub async fn disconnect(self)
[src]
Cleanly closes a connection with the server
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Client<'a>
impl<'a> Send for Client<'a>
impl<'a> Sync for Client<'a>
impl<'a> Unpin for Client<'a>
impl<'a> !UnwindSafe for Client<'a>
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,
pub 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.
pub 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,