1.0 Documentation

ClientXMPP

«  Event Index   ::   Contents   ::   ComponentXMPP  »

ClientXMPP

class sleekxmpp.clientxmpp.ClientXMPP(jid, password, plugin_config={}, plugin_whitelist=[], escape_quotes=True, sasl_mech=None, lang=u'en')[source]

SleekXMPP’s client class. (Use only for good, not for evil.)

Typical use pattern:

xmpp = ClientXMPP('user@server.tld/resource', 'password')
# ... Register plugins and event handlers ...
xmpp.connect()
xmpp.process(block=False) # block=True will block the current
                          # thread. By default, block=False
Parameters:
  • jid – The JID of the XMPP user account.
  • password – The password for the XMPP user account.
  • sslDeprecated.
  • plugin_config – A dictionary of plugin configurations.
  • plugin_whitelist – A list of approved plugins that will be loaded when calling register_plugins().
  • escape_quotesDeprecated.
connect(address=(), reattempt=True, use_tls=True, use_ssl=False)[source]

Connect to the XMPP server.

When no address is given, a SRV lookup for the server will be attempted. If that fails, the server user in the JID will be used.

:param address – A tuple containing the server’s host and port. :param reattempt: If True, repeat attempting to connect if an

error occurs. Defaults to True.
Parameters:
  • use_tls – Indicates if TLS should be used for the connection. Defaults to True.
  • use_ssl – Indicates if the older SSL connection method should be used. Defaults to False.
delRosterItem(jid)

Remove an item from the roster.

This is done by setting its subscription status to 'remove'.

Parameters:jid – The JID of the item to remove.
del_roster_item(jid)[source]

Remove an item from the roster.

This is done by setting its subscription status to 'remove'.

Parameters:jid – The JID of the item to remove.
getRoster(block=True, timeout=None, callback=None)

Request the roster from the server.

Parameters:
  • block – Specify if the roster request will block until a response is received, or a timeout occurs. Defaults to True.
  • timeout
    The length of time (in seconds) to wait for a response
    before continuing if blocking is used. Defaults to

    response_timeout.

  • callback – Optional reference to a stream handler function. Will be executed when the roster is received. Implies block=False.
get_roster(block=True, timeout=None, callback=None)[source]

Request the roster from the server.

Parameters:
  • block – Specify if the roster request will block until a response is received, or a timeout occurs. Defaults to True.
  • timeout
    The length of time (in seconds) to wait for a response
    before continuing if blocking is used. Defaults to

    response_timeout.

  • callback – Optional reference to a stream handler function. Will be executed when the roster is received. Implies block=False.
registerFeature(name, handler, restart=False, order=5000)

Register a stream feature handler.

Parameters:
  • name – The name of the stream feature.
  • handler – The function to execute if the feature is received.
  • restart – Indicates if feature processing should halt with this feature. Defaults to False.
  • order – The relative ordering in which the feature should be negotiated. Lower values will be attempted earlier when available.
register_feature(name, handler, restart=False, order=5000)[source]

Register a stream feature handler.

Parameters:
  • name – The name of the stream feature.
  • handler – The function to execute if the feature is received.
  • restart – Indicates if feature processing should halt with this feature. Defaults to False.
  • order – The relative ordering in which the feature should be negotiated. Lower values will be attempted earlier when available.
updateRoster(jid, **kwargs)

Add or change a roster item.

Parameters:
  • jid – The JID of the entry to modify.
  • name – The user’s nickname for this JID.
  • subscription – The subscription status. May be one of 'to', 'from', 'both', or 'none'. If set to 'remove', the entry will be deleted.
  • groups – The roster groups that contain this item.
  • block – Specify if the roster request will block until a response is received, or a timeout occurs. Defaults to True.
  • timeout
    The length of time (in seconds) to wait
    for a response before continuing if blocking is used. Defaults to

    response_timeout.

  • callback – Optional reference to a stream handler function. Will be executed when the roster is received. Implies block=False.
update_roster(jid, **kwargs)[source]

Add or change a roster item.

Parameters:
  • jid – The JID of the entry to modify.
  • name – The user’s nickname for this JID.
  • subscription – The subscription status. May be one of 'to', 'from', 'both', or 'none'. If set to 'remove', the entry will be deleted.
  • groups – The roster groups that contain this item.
  • block – Specify if the roster request will block until a response is received, or a timeout occurs. Defaults to True.
  • timeout
    The length of time (in seconds) to wait
    for a response before continuing if blocking is used. Defaults to

    response_timeout.

  • callback – Optional reference to a stream handler function. Will be executed when the roster is received. Implies block=False.

«  Event Index   ::   Contents   ::   ComponentXMPP  »