Gio.DBusConnection.prototype.add_filter
function add_filter(filter_function: Gio.DBusMessageFilterFunction): Number(guint) {
// Gjs wrapper for g_dbus_connection_add_filter()
}
Adds a message filter. Filters are handlers that are run on all incoming and outgoing messages, prior to standard dispatch. Filters are run in the order that they were added. The same handler can be added as a filter more than once, in which case it will be run more than once. Filters added during a filter callback won't be run on the message being processed. Filter functions are allowed to modify and even drop messages.
Note that filters are run in a dedicated message handling thread so they can't block and, generally, can't do anything but signal a worker thread. Also note that filters are rarely needed - use API such as Gio.DBusConnection.prototype.send_message_with_reply, Gio.DBusConnection.prototype.signal_subscribe or Gio.DBusConnection.prototype.call instead.
If a filter consumes an incoming message the message is not dispatched anywhere else - not even the standard dispatch machinery (that API such as Gio.DBusConnection.prototype.signal_subscribe and Gio.DBusConnection.prototype.send_message_with_reply relies on) will see the message. Similary, if a filter consumes an outgoing message, the message will not be sent to the other peer.
Since 2.26
- filter_function
a filter function
- Returns
a filter identifier that can be used with Gio.DBusConnection.prototype.remove_filter