[−][src]Struct wamp_async::Client
Allows interaction as a client with a WAMP server
Methods
impl Client
[src]
pub async fn connect<T: AsRef<str>>(
uri: T,
cfg: Option<ClientConfig>
) -> Result<Self, WampError>
[src]
uri: T,
cfg: Option<ClientConfig>
) -> Result<Self, WampError>
Connects to a WAMP server using the specified protocol
Currently supported protocols are :
- WebSocket :
ws://some.site.com/wamp
| (Secure)wss://localhost:8080
- RawSocket :
tcp://some.site.com:80
| (Secure)tcps://localhost:443
Extra customization can be specified through the ClientConfig struct
pub fn event_loop(
&mut self
) -> Result<(Pin<Box<dyn Future<Output = ()> + Send>>, Option<UnboundedReceiver<GenericFuture>>), WampError>
[src]
&mut self
) -> Result<(Pin<Box<dyn Future<Output = ()> + Send>>, Option<UnboundedReceiver<GenericFuture>>), WampError>
This function must be called by the client after a succesful connection. It returns a future for the event loop which MUST be executed by the caller. It also returns the receiving end of a channel (if the client has the 'callee' role) which is reponsible for receiving RPC call futures. The caller is also responsible for executing the RPC call futures in whatever way they wish.async_trait
This allows the caller to use whatever runtime & task execution method they wish
pub async fn join_realm<'_, T: AsRef<str>>(
&'_ 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
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, WampArgs, WampKwArgs)>), WampError>
[src]
&'_ self,
topic: T
) -> Result<(WampId, UnboundedReceiver<(WampId, WampArgs, 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: WampArgs,
arguments_kw: WampKwArgs,
acknowledge: bool
) -> Result<WampId, WampError>
[src]
&'_ self,
topic: T,
arguments: WampArgs,
arguments_kw: WampKwArgs,
acknowledge: bool
) -> Result<WampId, WampError>
Publishes an event on a specifiec 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(WampArgs, WampKwArgs) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(WampArgs, WampKwArgs), WampError>> + Send + 'static,
[src]
&'_ self,
uri: T,
func_ptr: F
) -> Result<WampId, WampError> where
T: AsRef<str>,
F: Fn(WampArgs, WampKwArgs) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(WampArgs, WampKwArgs), WampError>> + Send + 'static,
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: WampArgs,
arguments_kw: WampKwArgs
) -> Result<(WampArgs, WampKwArgs), WampError>
[src]
&'_ self,
uri: T,
arguments: WampArgs,
arguments_kw: WampKwArgs
) -> Result<(WampArgs, WampKwArgs), WampError>
Calls a registered RPC endpoint on the server
pub fn get_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(__arg0: Self)
[src]
Cleanly closes a connection with the server
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl !Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
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>,