Package pyxmpp :: Module client :: Class Client
[show private | hide private]
[frames | no frames]

Class Client

Known Subclasses:
JabberClient

Base class for an XMPP-IM client.

This class does not provide any JSF extensions to the XMPP protocol,
including legacy authentication methods.

:Ivariables:
    - `jid`: configured JID of the client (current actual JID
      is avialable as `self.stream.jid`).
    - `password`: authentication password.
    - `server`: server to use if non-standard and not discoverable
      by SRV lookups.
    - `port`: port number on the server to use if non-standard and not
      discoverable by SRV lookups.
    - `auth_methods`: methods allowed for stream authentication. SASL
      mechanism names should be preceded with "sasl:" prefix.
    - `keepalive`: keepalive interval for the stream or 0 when keepalive is
      disabled.
    - `stream`: current stream when the client is connected,
      `None` otherwise.
    - `roster`: user's roster or `None` if the roster is not yet retrieved.
    - `session_established`: `True` when an IM session is established.
    - `lock`: lock for synchronizing `Client` attributes access.
    - `state_changed`: condition notified the the object state changes
      (stream becomes connected, session established etc.).
:Types:
    - `jid`: `pyxmpp.JID`
    - `password`: `unicode`
    - `server`: `unicode`
    - `port`: `int`
    - `auth_methods`: `list` of `str`
    - `keepalive`: `int`
    - `stream`: `pyxmpp.ClientStream`
    - `roster`: `pyxmpp.Roster`
    - `session_established`: `bool`
    - `lock`: `threading.RLock`
    - `state_changed`: `threading.Condition`

Method Summary
  __init__(self, jid, password, server, port, auth_methods, tls_settings, keepalive)
Initialize a Client object.
  authenticated(self)
Handle "authenticated" event.
  authorized(self)
Handle "authorized" event.
  connect(self, register)
Connect to the server and set up the stream.
  connected(self)
Handle "connected" event.
  disconnect(self)
Disconnect from the server.
  disconnected(self)
Handle "disconnected" event.
  get_socket(self)
Get the socket object of the active connection.
  get_stream(self)
Get the connected stream object.
  idle(self)
Do some "housekeeping" work like cache expiration or timeout handling.
  loop(self, timeout)
Simple "main loop" for the client.
  request_roster(self)
Request the user's roster.
  request_session(self)
Request an IM session.
  roster_updated(self, item)
Handle roster update event.
  session_started(self)
Handle session started event.
  stream_closed(self, stream)
Handle stream closure event.
  stream_created(self, stream)
Handle stream creation event.
  stream_error(self, err)
Handle stream error received.
  stream_state_changed(self, state, arg)
Handle any stream state change.

Method Details

__init__(self, jid=None, password=None, server=None, port=5222, auth_methods=('sasl:DIGEST-MD5',), tls_settings=None, keepalive=0)
(Constructor)

Initialize a Client object.

:Parameters:
    - `jid`: user full JID for the connection.
    - `password`: user password.
    - `server`: server to use. If not given then address will be derived form the JID.
    - `port`: port number to use. If not given then address will be derived form the JID.
    - `auth_methods`: sallowed authentication methods. SASL authentication mechanisms
      in the list should be prefixed with "sasl:" string.
    - `tls_settings`: settings for StartTLS -- `TLSSettings` instance.
    - `keepalive`: keepalive output interval. 0 to disable.
:Types:
    - `jid`: `pyxmpp.JID`
    - `password`: `unicode`
    - `server`: `unicode`
    - `port`: `int`
    - `auth_methods`: sequence of `str`
    - `tls_settings`: `pyxmpp.TLSSettings`
    - `keepalive`: `int`

authenticated(self)

Handle "authenticated" event. May be overriden in derived classes.
This one does nothing.

authorized(self)

Handle "authorized" event. May be overriden in derived classes.
This one requests an IM session.

connect(self, register=False)

Connect to the server and set up the stream.

Set `self.stream` and notify `self.state_changed` when connection
succeeds.

connected(self)

Handle "connected" event. May be overriden in derived classes.
This one does nothing.

disconnect(self)

Disconnect from the server.

disconnected(self)

Handle "disconnected" event. May be overriden in derived classes.
This one does nothing.

get_socket(self)

Get the socket object of the active connection.

:return: socket used by the stream.
:returntype: `socket.socket`

get_stream(self)

Get the connected stream object.

:return: stream object or `None` if the client is not connected.
:returntype: `pyxmpp.ClientStream`

idle(self)

Do some "housekeeping" work like cache expiration or timeout
handling. Should be called periodically from the application main
loop. May be overriden in derived classes.

loop(self, timeout=1)

Simple "main loop" for the client.

By default just call the `pyxmpp.Stream.loop_iter` method of
`self.stream`, which handles stream input and `self.idle` for some
"housekeeping" work until the stream is closed.

This usually will be replaced by something more sophisticated. E.g.
handling of other input sources.

request_roster(self)

Request the user's roster.

request_session(self)

Request an IM session.

roster_updated(self, item=None)

Handle roster update event. May be overriden in derived classes.
This one does nothing.

:Parameters:
    - `item`: the roster item changed or `None` if whole roster was
      received.
:Types:
    - `item`: `pyxmpp.RosterItem`

session_started(self)

Handle session started event. May be overriden in derived classes.
This one requests the user's roster and sends the initial presence.

stream_closed(self, stream)

Handle stream closure event. May be overriden in derived classes.
This one does nothing.

:Parameters:
    - `stream`: the new stream.
:Types:
    - `stream`: `pyxmpp.ClientStream`

stream_created(self, stream)

Handle stream creation event. May be overriden in derived classes.
This one does nothing.

:Parameters:
    - `stream`: the new stream.
:Types:
    - `stream`: `pyxmpp.ClientStream`

stream_error(self, err)

Handle stream error received. May be overriden in derived classes.
This one passes an error messages to logging facilities.

:Parameters:
    - `err`: the error element received.
:Types:
    - `err`: `pyxmpp.error.StreamErrorNode`

stream_state_changed(self, state, arg)

Handle any stream state change. May be overriden in derived classes.
This one does nothing.

:Parameters:
    - `state`: the new state.
    - `arg`: state change argument.
:Types:
    - `state`: `str`

Generated by Epydoc 2.1 on Wed May 31 22:36:58 2006 http://epydoc.sf.net