Skip to content
Back to top
View this page

# ClientXMPP

class slixmpp.clientxmpp.ClientXMPP(jid, password, plugin_config=None, plugin_whitelist=None, escape_quotes=True, sasl_mech=None, lang='en', **kwargs)

  Slixmpp’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()
      asyncio.get_event_loop().run_forever()

  Parameters:

    - jid (`str` | `JID`) – The JID of the XMPP user account.

    - password (`str`) – The password for the XMPP user account.

    - plugin_config – A dictionary of plugin configurations.

    - plugin_whitelist – A list of approved plugins that will be loaded when calling `register_plugins()`.

    - escape_quotes – Deprecated.

  client_roster: `RosterNode`

    The single roster for the bound JID. This is the equivalent of:

        self.roster[self.boundjid.bare]

  connect(host=None, port=None)

    Connect to the XMPP server.

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

    Parameters:

      - host (`str` | `None`) – A custom host to connect to (requires port as well)

      - port (`int` | `None`) – A custom port to connect to (requires host as well)

    Return type:

      `Future`

  del_roster_item(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.

  get_roster(callback=None, timeout=None)

    Request the roster from the server.

    Parameters:

      callback – Reference to a stream handler function. Will be executed when the roster is received.

    Return type:

      `Future`[`Iq` | `None`]

  register_feature(name, handler, restart=False, order=5000)

    Register a stream feature handler.

    Parameters:

      - name (`str`) – The name of the stream feature.

      - handler (`Callable`) – The function to execute if the feature is received.

      - restart (`bool`) – Indicates if feature processing should halt with this feature. Defaults to `False`.

      - order (`int`) – The relative ordering in which the feature should be negotiated. Lower values will be attempted earlier when available.

    Return type:

      `None`

  update_roster(jid, **kwargs)

    Add or change a roster item.

    Parameters:

      - jid (`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.

      - 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`.

    Return type:

      `None`