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.
1.1.13.2. Classes¶
-
class
ServerEventSubscriber
(rpc)[source]¶ Bases:
gi.overrides.GObject.Object
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.
-
connect_data
(detailed_signal, handler, *data, **kwargs)[source]¶ Connect a callback to the given signal with optional user data.
- Parameters
detailed_signal (str) – A detailed signal to connect to.
handler (callable) – Callback handler to connect to the signal.
*data –
Variable data which is passed through to the signal handler.
connect_flags (GObject.ConnectFlags) – Flags used for connection options.
- Returns
A signal id which can be used with disconnect.
-
freeze_notify
()[source]¶ Freezes the object’s property-changed notification queue.
- Returns
A context manager which optionally can be used to automatically thaw notifications.
This will freeze the object so that “notify” signals are blocked until the thaw_notify() method is called.
with obj.freeze_notify(): pass
-
handler_block
(handler_id)[source]¶ Blocks the signal handler from being invoked until handler_unblock() is called.
- Parameters
obj (GObject.Object) – Object instance to block handlers for.
handler_id (int) – Id of signal to block.
- Returns
A context manager which optionally can be used to automatically unblock the handler:
with GObject.signal_handler_block(obj, id): pass
-
handler_is_connected
[source]¶ signal_handler_is_connected(instance:GObject.Object, handler_id:int) -> bool
-
is_subscribed
(event_id, event_type)[source]¶ Check if the client is currently subscribed to the specified server event.
-
reconnect
[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.
-
stop_emission_by_name
[source]¶ signal_stop_emission_by_name(instance:GObject.Object, detailed_signal:str)
-
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.
-