Client Variable interfaces

class osmxmpp.client.XmppClientInterface(client, obj, permissions)

Bases: object

Xmpp client interface implementation. Used by Features or Extensions to interact with the XMPP client.

change_socket(socket)

Changes the socket of the XMPP client. Requires the CHANGE_SOCKET permission.

Parameters:

socket (socket) – The new socket of the XMPP client.

disconnect()

Disconnects from the XMPP server. Requires the DISCONNECT permission.

get_host()

Gets the host of the XMPP client. Requires the GET_HOST permission.

Returns:

The host of the XMPP client.

Return type:

str

get_jid(with_resouce=True)

Gets the JID of the XMPP client. Requires the GET_JID permission.

Parameters:

with_resouce (bool) – Whether to include the resource in the JID. (Default: True)

Returns:

The JID of the XMPP client.

Return type:

str

get_port()

Gets the port of the XMPP client. Requires the GET_PORT permission.

Returns:

The port of the XMPP client.

Return type:

int

get_resource()

Gets the resource of the XMPP client. Requires the GET_RESOURCE or GET_JID permissions.

Returns:

The resource of the XMPP client.

Return type:

str

get_socket()

Gets the socket of the XMPP client. Requires the GET_SOCKET permission.

Returns:

The socket of the XMPP client.

Return type:

socket

has_permission(*permissions)

Checks if the client interface has the given permission.

Parameters:

permissions (XmppPermission) – The permissions to check.

Returns:

True if the client interface has the permission, False otherwise.

Return type:

bool

hook_on_iq(hook)

Registers a hook for the iq event. The hook will be called when the client receives an iq stanza.

Parameters:

hook (Callable) – The hook to register.

Returns:

The hook (not changed).

Return type:

Callable

hook_on_message(hook)

Registers a hook for the message event. The hook will be called when the client receives a message stanza.

Parameters:

hook (Callable) – The hook to register.

Returns:

The hook (not changed).

Return type:

Callable

hook_on_presence(hook)

Registers a hook for the presence event. The hook will be called when the client receives a presence stanza.

Parameters:

hook (Callable) – The hook to register.

Returns:

The hook (not changed).

Return type:

Callable

hook_send_message(hook)

Registers a hook for the send message event. The hook will be called when the client sends a message.

Parameters:

hook (Callable) – The hook to register.

Returns:

The hook (not changed).

Return type:

Callable

on_connect(handler)

Registers a handler for the connected event. The handler will be called when the client is connected to the XMPP server, but not ready yet.

Parameters:

handler (Callable) – The handler to register.

Returns:

The handler (not changed).

Return type:

Callable

on_disconnect(handler)

Registers a handler for the disconnected event. The handler will be called when the client is disconnected from the XMPP server.

Parameters:

handler (Callable) – The handler to register.

Returns:

The handler (not changed).

Return type:

Callable

on_iq(handler)

Registers a handler for the iq event. The handler will be called when the client receives an iq stanza.

Parameters:

handler (Callable) – The handler to register.

Returns:

The handler (not changed).

Return type:

Callable

on_message(handler)

Registers a handler for the message event. The handler will be called when the client receives a message stanza.

Parameters:

handler (Callable) – The handler to register.

Returns:

The handler (not changed).

Return type:

Callable

on_presence(handler)

Registers a handler for the presence event. The handler will be called when the client receives a presence stanza.

Parameters:

handler (Callable) – The handler to register.

Returns:

The handler (not changed).

Return type:

Callable

on_ready(handler)

Registers a handler for the ready event. The handler will be called when the client is ready to send and receive XMPP stanzas.

Parameters:

handler (Callable) – The handler to register.

Returns:

The handler (not changed).

Return type:

Callable

open_stream()

Opens the XMPP stream. Requires the OPEN_STREAM permission.

recv_xml()

Receives an XML element from the XMPP client. Requires the RECV_XML permission.

Returns:

The XML element received.

Return type:

XmlElement

send_xml(xml)

Sends an XML element to the XMPP client. Requires the SEND_XML permission.

Parameters:

xml (XmlElement) – The XML element to send.

Returns:

The XML element sent.

Return type:

XmlElement

set_jid(jid)

Sets the JID of the XMPP client. Requires the SET_JID permission.

Parameters:

jid (str) – The new JID of the XMPP client.

set_resource(resource)

Sets the resource of the XMPP client. Requires the SET_RESOURCE permission.

Parameters:

resource (str) – The new resource of the XMPP client.

class osmxmpp.ci.XmppVariableInterface(ci)

Bases: object

Xmpp variable interface implementation. Used by Features or Extensions to expose variables

function(function)

Registers a function to the variable.

Parameters:

function (Callable) – The function to register.

Returns:

The function (not changed).

Return type:

Callable