aiowamp.Client¶
-
class
aiowamp.Client(session)[source]¶ Initialise the client.
A client is just a wrapper for a session. It takes full control over the session, so when the client closes so will the session.
Parameters: session ( SessionABC) – Session to wrap.-
__init__(session)[source]¶ Initialise the client.
A client is just a wrapper for a session. It takes full control over the session, so when the client closes so will the session.
Parameters: session ( SessionABC) – Session to wrap.Return type: None
Methods
__init__(session)Initialise the client. call(procedure, *args[, kwargs, …])Call a remote procedure. close([details, reason])Close the client and the underlying session. get_registration_ids(procedure)Get the ids of the registrations for the given procedure. get_subscription_ids(topic)Get the ids of the subscriptions for the given topic. publish(topic, *args[, kwargs, acknowledge, …])Publish an event to a topic. register(procedure, handler, *[, …])Register a procedure. subscribe(topic, callback, *[, …])Subscribe to a topic. unregister(procedure[, registration_id])Unregister a procedure. unsubscribe(topic[, subscription_id])Unsubscribe from the given topic. wait_until_done()Wait until the client is done. Attributes
id_genID generator used to generate the client ids. sessionSession the client is attached to. -
__init__(session)[source] Initialise the client.
A client is just a wrapper for a session. It takes full control over the session, so when the client closes so will the session.
Parameters: session ( SessionABC) – Session to wrap.Return type: None
-
session¶ Session the client is attached to.
-
id_gen¶ ID generator used to generate the client ids.
-
close(details=None, *, reason=None)[source]¶ Close the client and the underlying session.
Parameters: Return type: None
-
publish(topic, *args, kwargs=None, acknowledge=None, blackwhitelist=None, exclude_me=None, disclose_me=None, resource_key=None, options=None)[source]¶ Publish an event to a topic.
Parameters: - topic (
str) – Topic uri to publish to. - *args – Arguments for the event.
- kwargs (
Optional[Dict[str,ForwardRef]]) – Keyword arguments for the event. - acknowledge (
Optional[bool]) – Whether to wait for the router to acknowledge the event. - blackwhitelist (
Optional[BlackWhiteList]) – Black- and whitelisting subscribers. - exclude_me (
Optional[bool]) – Whether the client should receive this event. - disclose_me (
Optional[bool]) – Whether the client’s identity should be disclosed to subscribers. - resource_key (
Optional[str]) – Resource key for sharded subscriptions. - options (
Optional[Dict[str,ForwardRef]]) – Additional options. - args (
Union[int,str,bool,ForwardRef,ForwardRef]) –
Return type: None- topic (
-
register(procedure, handler, *, disclose_caller=None, match_policy=None, invocation_policy=None, options=None)[source]¶ Register a procedure.
Parameters: - procedure (
str) – Procedure URI to register. - handler (
Callable[[ForwardRef],Union[Awaitable[ForwardRef],AsyncGenerator[ForwardRef,None]]]) – Procedure to call. - disclose_caller (
Optional[bool]) – Whether callers’ identities should be disclosed. - match_policy (
Optional[NewType()(MatchPolicy,str)]) – Match policy for the procedure uri. Can also be specified by passing anaiowamp.URIwith a match policy to the procedure. - invocation_policy (
Optional[NewType()(InvocationPolicy,str)]) – Invocation policy. - options (
Optional[Dict[str,ForwardRef]]) – Additional options to pass.
Return type: Returns: The registration id of the registered procedure. Can be used to unregister the procedure.
- procedure (
-
subscribe(topic, callback, *, match_policy=None, node_key=None, options=None)[source]¶ Subscribe to a topic.
Parameters: - topic (
str) – Topic uri to subscribe to. - callback (
Callable[[ForwardRef],Union[Any,Awaitable[Any]]]) – Callable to call for each event. - match_policy (
Optional[NewType()(MatchPolicy,str)]) – Match policy for the uri. Can also be specified by passing anaiowamp.URIwith a match policy. - node_key (
Optional[str]) – Node key for sharded subscriptions. - options (
Optional[Dict[str,ForwardRef]]) – Additional options to pass.
Return type: - topic (
-
unregister(procedure, registration_id=None)[source]¶ Unregister a procedure.
Parameters: Raises: KeyError– If no registration for the procedure exists.Return type: None
-
unsubscribe(topic, subscription_id=None)[source]¶ Unsubscribe from the given topic.
Parameters: Raises: KeyError– If not subscribed to the topic.Return type: None
-
get_registration_ids(procedure)[source]¶ Get the ids of the registrations for the given procedure.
Parameters: procedure ( str) – Procedure to get registration ids for.Return type: Tuple[int, …]Returns: Tuple containing the registration ids.
-
call(procedure, *args, kwargs=None, receive_progress=None, call_timeout=None, cancel_mode=None, disclose_me=None, resource_key=None, options=None)[source]¶ Call a remote procedure.
Parameters: - procedure (
str) – Procedure uri to call. - *args – Arguments to pass to the call.
- kwargs (
Optional[Dict[str,ForwardRef]]) – Keyword arguments to pass to the call. - receive_progress (
Optional[bool]) – Whether the callee may send progress results. - call_timeout (
Optional[float]) – Timeout in seconds for the call. - cancel_mode (
Optional[NewType()(CancelMode,str)]) – Cancel mode to use when cancelling the call. Seeaiowamp.Call.cancel. - disclose_me (
Optional[bool]) – Whether to disclose the client to the callee. - resource_key (
Optional[str]) – Resource key for sharded registrations. - options (
Optional[Dict[str,ForwardRef]]) – Additional options to pass. - args (
Union[int,str,bool,ForwardRef,ForwardRef]) –
Return type: CallABCReturns: The call instance to interact with the call.
- procedure (
-