1.1.13. server_events
¶
This module provides functionality to allow the client application to subscribe to events which are published by the server.
1.1.13.1. Functions¶
-
event_type_filter
(event_types, is_method=False)[source]¶ A decorator to filter a signal handler by the specified event types. Using this will ensure that the decorated function is only called for the specified event types and not others which may have been subscribed to elsewhere in the application.
Parameters:
1.1.13.2. Classes¶
-
class
ServerEventSubscriber
(rpc)[source]¶ Bases:
GObject.GObject
An object which provides functionality to subscribe to events that are published by the remote King Phisher server instance. This object manages the subscriptions and forwards the events allowing consumers to connect to the available GObject signals.
Note
Both the
ServerEventSubscriber.subscribe()
andServerEventSubscriber.unsubscribe()
methods of this object internally implement reference counting for the server events. This makes it possible for multiple subscriptions to be created and deleted without interfering with each other.The socket is opened automatically when this object is initialized and will automatically attempt to reconnect if the connection is closed if the
reconnect
attribute is true. After initializing this object, check theis_connected
attribute to ensure that it is properly connected to the server.-
__init__
(rpc)[source]¶ Parameters: rpc ( KingPhisherRPCClient
) – The client’s connected RPC instance.
-
is_subscribed
(event_id, event_type)[source]¶ Check if the client is currently subscribed to the specified server event.
Parameters: Returns: Whether or not the client is subscribed to the event.
Return type:
-
reconnect
= None[source]¶ Whether or not the socket should attempt to reconnect itself when it has been closed.
-
shutdown
()[source]¶ Disconnect the event socket from the remote server. After the object is shutdown, remove events will no longer be published.
Parameters: timeout (int) – An optional timeout for how long to wait on the worker thread.
-
subscribe
(event_id, event_types, attributes)[source]¶ Subscribe the client to the specified event published by the server. When the event is published the specified attributes of it and it’s corresponding id and type information will be sent to the client.
Parameters:
-