Package xmpp :: Module dispatcher :: Class Dispatcher
[show private | hide private]
[frames | no frames]

Class Dispatcher

PlugIn --+
         |
        Dispatcher


Ancestor of PlugIn class. Handles XMPP stream, i.e. aware of stream headers. Can be plugged out/in to restart these headers (used for SASL f.e.).
Method Summary
  __init__(self)
  disconnect(self)
Send a stream terminator and and handle all incoming stanzas before stream closure.
  dispatch(self, stanza, session)
Main procedure that performs XMPP stanza recognition and calling apppropriate handlers for it.
  dumpHandlers(self)
Return set of user-registered callbacks in it's internal format.
  Event(self, realm, event, data)
Raise some event.
  plugin(self, owner)
Plug the Dispatcher instance into Client class instance and send initial stream header.
  plugout(self)
  Process(self, timeout)
Check incoming stream for data waiting.
  RegisterCycleHandler(self, handler)
Register handler that will be called on every Dispatcher.Process() call.
  RegisterDefaultHandler(self, handler)
Specify the handler that will be used if no NodeProcessed exception were raised.
  RegisterEventHandler(self, handler)
Register handler that will process events.
  RegisterHandler(self, name, handler, typ, ns, xmlns, makefirst, system)
Register user callback as stanzas handler of declared type.
  RegisterHandlerOnce(self, name, handler, typ, ns, xmlns, makefirst, system)
Unregister handler after first call (not implemented yet).
  RegisterNamespace(self, xmlns, order)
Creates internal structures for newly registered namespace.
  RegisterNamespaceHandler(self, xmlns, handler, typ, ns, makefirst, system)
Register handler for processing all stanzas for specified namespace.
  RegisterProtocol(self, tag_name, Proto, xmlns, order)
Used to declare some top-level stanza name to dispatcher.
  restoreHandlers(self, handlers)
Restores user-registered callbacks structure from dump previously obtained via dumpHandlers.
  returnStanzaHandler(self, conn, stanza)
Return stanza back to the sender with <feature-not-implemennted/> error set.
  send(self, stanza)
Serialise stanza and put it on the wire.
  SendAndWaitForResponse(self, stanza, timeout)
Put stanza on the wire and wait for recipient's response to it.
  StreamInit(self)
Send an initial stream header.
  UnregisterCycleHandler(self, handler)
Unregister handler that will is called on every Dispatcher.Process() call.
  UnregisterHandler(self, name, handler, typ, ns, xmlns)
Unregister handler.
  WaitForResponse(self, ID, timeout)
Block and wait until stanza with specific "id" attribute will come.
  _init(self)
    Inherited from PlugIn
  DEBUG(self, text, severity)
Feed a provided debug line to main instance's debug facility along with our ID string.
  PlugIn(self, owner)
Attach to main instance and register ourself and all our staff in it.
  PlugOut(self)
Unregister all our staff from main instance and detach from it.

Method Details

disconnect(self)

Send a stream terminator and and handle all incoming stanzas before stream closure.

dispatch(self, stanza, session=None)

Main procedure that performs XMPP stanza recognition and calling apppropriate handlers for it. Called internally.

dumpHandlers(self)

Return set of user-registered callbacks in it's internal format. Used within the library to carry user handlers set over Dispatcher replugins.

Event(self, realm, event, data)

Raise some event. Takes three arguments: 1) "realm" - scope of event. Usually a namespace. 2) "event" - the event itself. F.e. "SUCESSFULL SEND". 3) data that comes along with event. Depends on event.

plugin(self, owner)

Plug the Dispatcher instance into Client class instance and send initial stream header. Used internally.

Process(self, timeout=0)

Check incoming stream for data waiting. If "timeout" is positive - block for as max. this time. Returns: 1) length of processed data if some data were processed; 2) '0' string if no data were processed but link is alive; 3) 0 (zero) if underlying connection is closed.

RegisterCycleHandler(self, handler)

Register handler that will be called on every Dispatcher.Process() call.

RegisterDefaultHandler(self, handler)

Specify the handler that will be used if no NodeProcessed exception were raised. This is returnStanzaHandler by default.

RegisterEventHandler(self, handler)

Register handler that will process events. F.e. "FILERECEIVED" event.

RegisterHandler(self, name, handler, typ='', ns='', xmlns=None, makefirst=0, system=0)

Register user callback as stanzas handler of declared type. Callback must take
(if chained, see later) arguments: dispatcher instance (for replying), incomed
return of previous handlers.
The callback must raise xmpp.NodeProcessed just before return if it want preven
callbacks to be called with the same stanza as argument _and_, more importantly
library from returning stanza to sender with error set (to be enabled in 0.2 ve
 Arguments:
   "name" - name of stanza. F.e. "iq".
   "handler" - user callback.
   "typ" - value of stanza's "type" attribute. If not specified any value match
   "ns" - namespace of child that stanza must contain.
   "chained" - chain together output of several handlers.
   "makefirst" - insert handler in the beginning of handlers list instead of
     adding it to the end. Note that more common handlers (i.e. w/o "typ" and "
     will be called first nevertheless.
   "system" - call handler even if NodeProcessed Exception were raised already.

RegisterHandlerOnce(self, name, handler, typ='', ns='', xmlns=None, makefirst=0, system=0)

Unregister handler after first call (not implemented yet).

RegisterNamespace(self, xmlns, order='info')

Creates internal structures for newly registered namespace. You can register handlers for this namespace afterwards. By default one namespace already registered (jabber:client or jabber:component:accept depending on context.

RegisterNamespaceHandler(self, xmlns, handler, typ='', ns='', makefirst=0, system=0)

Register handler for processing all stanzas for specified namespace.

RegisterProtocol(self, tag_name, Proto, xmlns=None, order='info')

Used to declare some top-level stanza name to dispatcher. Needed to start registering handlers for such stanzas. Iq, message and presence protocols are registered by default.

restoreHandlers(self, handlers)

Restores user-registered callbacks structure from dump previously obtained via dumpHandlers. Used within the library to carry user handlers set over Dispatcher replugins.

returnStanzaHandler(self, conn, stanza)

Return stanza back to the sender with <feature-not-implemennted/> error set.

send(self, stanza)

Serialise stanza and put it on the wire. Assign an unique ID to it before send. Returns assigned ID.

SendAndWaitForResponse(self, stanza, timeout=25)

Put stanza on the wire and wait for recipient's response to it.

StreamInit(self)

Send an initial stream header.

UnregisterCycleHandler(self, handler)

Unregister handler that will is called on every Dispatcher.Process() call.

UnregisterHandler(self, name, handler, typ='', ns='', xmlns=None)

Unregister handler. "typ" and "ns" must be specified exactly the same as with registering.

WaitForResponse(self, ID, timeout=25)

Block and wait until stanza with specific "id" attribute will come. If no such stanza is arrived within timeout, return None. If operation failed for some reason then owner's attributes lastErrNode, lastErr and lastErrCode are set accordingly.

Generated by Epydoc 2.1 on Sun Dec 26 09:52:56 2004 http://epydoc.sf.net