1.1.13. server_events

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:
  • event_types (list, str) – A single event type as a string or a list of event type strings.
  • is_method (bool) – Whether or not the function being decorated is a class method.

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() and ServerEventSubscriber.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 the is_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.

emit_stop_by_name(detailed_signal)[source]

Deprecated, please use stop_emission_by_name.

classmethod find_property(self, property_name:str) → GObject.ParamSpec[source]
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
getv = gi.FunctionInfo(getv)[source]
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
classmethod install_properties(self, pspecs:list)[source]
classmethod install_property(self, property_id:int, pspec:GObject.ParamSpec)[source]
is_connected[source]

True if the event socket is connected to the server.

is_floating = gi.FunctionInfo(is_floating)[source]
is_subscribed(event_id, event_type)[source]

Check if the client is currently subscribed to the specified server event.

Parameters:
  • event_id (str) – The identifier of the event to subscribe to.
  • event_type (str) – A sub-type for the corresponding event.
Returns:

Whether or not the client is subscribed to the event.

Return type:

bool

classmethod list_properties(self) → list, n_properties:int[source]
newv = gi.FunctionInfo(newv)[source]
notify = gi.FunctionInfo(notify)[source]
classmethod override_property(self, property_id:int, name:str)[source]
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.
stop_emission(detailed_signal)[source]

Deprecated, please use stop_emission_by_name.

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:
  • event_id (str) – The identifier of the event to subscribe to.
  • event_types (list) – A list of sub-types for the corresponding event.
  • attributes (list) – A list of attributes of the event object to be sent to the client.
thaw_notify = gi.FunctionInfo(thaw_notify)[source]
unsubscribe(event_id, event_types, attributes)[source]

Unsubscribe from an event published by the server that the client previously subscribed to.

Parameters:
  • event_id (str) – The identifier of the event to subscribe to.
  • event_types (list) – A list of sub-types for the corresponding event.
  • attributes (list) – A list of attributes of the event object to be sent to the client.