Home | Trees | Index | Help |
|
---|
Package pyxmpp :: Module streambase :: Class StreamBase |
|
StanzaProcessor
--+ |StreamHandler
--+ | StreamBase
Stream
Base class for a generic XMPP stream. Responsible for establishing connection, parsing the stream, dispatching received stanzas to apopriate handlers and sending application's stanzas. This doesn't provide any authentication or encryption (both required by the XMPP specification) and is not usable on its own. Whenever we say "stream" here we actually mean two streams (incoming and outgoing) of one connections, as defined by the XMPP specification. :Ivariables: - `lock`: RLock object used to synchronize access to Stream object. - `features`: stream features as annouced by the initiator. - `me`: local stream endpoint JID. - `peer`: remote stream endpoint JID. - `process_all_stanzas`: when `True` then all stanzas received are considered local. - `initiator`: `True` if local stream endpoint is the initiating entity. - `_reader`: the stream reader object (push parser) for the stream.
Method Summary | |
---|---|
Initialize Stream object :Parameters: - `default_ns`: stream's default namespace ("jabber:client" for client, "jabber:server" for server, etc.) - `extra_ns`: sequence of extra namespace URIs to be defined for the stream. | |
__del__(self)
| |
Accept incoming connection. | |
Bind to a resource. | |
Check "to" attribute of received stream header. | |
Forcibly close the connection and clear the stream state. | |
Establish XMPP connection with given address. | |
Check if stream is connected. | |
Gracefully close the connection. | |
Handle stream XML parse error. | |
Return filedescriptor of the stream socket. | |
Generate a random and unique stream ID. | |
Do some housekeeping (cache expiration, timeout handling). | |
Simple "main loop" for the stream. | |
Single iteration of a simple "main loop" for the stream. | |
Process stream's pending events. | |
Process stream error element received. | |
Write stanza to the stream. | |
Process stanza (first level child element of the stream). | |
Process stanza (first level child element of the stream) start tag -- do nothing. | |
Called when connection state is changed. | |
Process </stream:stream> (stream end) tag received from peer. | |
Process <stream:stream> (stream start) tag received from peer. | |
Write raw data to the stream socket. | |
Inherited from StanzaProcessor | |
Modify incoming stanza before processing it. | |
Modify outgoing stanza before sending into the stream. | |
Process IQ stanza received. | |
Process message stanza. | |
Process presence stanza. | |
Process stanza received from the stream. | |
Process stanza not addressed to us. | |
Set <iq type="get"/> handler. | |
Set <iq type="set"/> handler. | |
Set a handler for <message/> stanzas. | |
Set a handler for <presence/> stanzas. | |
Set response handler for an IQ "get" or "set" stanza. | |
Remove <iq type="get"/> handler. | |
Remove <iq type="set"/> handler. |
Method Details |
---|
__init__(self,
default_ns,
extra_ns=(),
keepalive=0)
|
accept(self, sock, myname)Accept incoming connection. [receiving entity only] :Parameters: - `sock`: a listening socket. - `myname`: local stream endpoint name. |
bind(self, resource)Bind to a resource. [initiating entity only] :Parameters: - `resource`: the resource name to bind to. XMPP stream is authenticated for bare JID only. To use the full JID it must be bound to a resource. |
check_to(self, to)Check "to" attribute of received stream header. :return: `to` if it is equal to `self.me`, None otherwise. Should be overriden in derived classes which require other logic for handling that attribute. |
close(self)Forcibly close the connection and clear the stream state. |
connect(self, addr, port, service=None, to=None)Establish XMPP connection with given address. [initiating entity only] :Parameters: - `addr`: peer name or IP address - `port`: port number to connect to - `service`: service name (to be resolved using SRV DNS records) - `to`: peer name if different than `addr` |
connected(self)Check if stream is connected. :return: True if stream connection is active. |
disconnect(self)Gracefully close the connection. |
error(self, descr)Handle stream XML parse error. :Parameters: - `descr`: error description
|
fileno(self)Return filedescriptor of the stream socket. |
generate_id(self)Generate a random and unique stream ID. :return: the id string generated. |
idle(self)Do some housekeeping (cache expiration, timeout handling). This method should be called periodically from the application's main loop. |
loop(self, timeout)Simple "main loop" for the stream. |
loop_iter(self, timeout)Single iteration of a simple "main loop" for the stream. |
process(self)Process stream's pending events. Should be called whenever there is input available on `self.fileno()` socket descriptor. Is called by `self.loop_iter`. |
process_stream_error(self, err)Process stream error element received. :Types: - `err`: `StreamErrorNode` :Parameters: - `err`: error received |
send(self, stanza)Write stanza to the stream. :Parameters: - `stanza`: XMPP stanza to send.
|
stanza(self, _unused, node)Process stanza (first level child element of the stream). :Parameters: - `_unused`: parsed document - `node`: stanza's full XML
|
stanza_start(self, doc, node)Process stanza (first level child element of the stream) start tag -- do nothing. :Parameters: - `doc`: parsed document - `node`: stanza's full XML |
state_change(self, state, arg)Called when connection state is changed. This method is supposed to be overriden in derived classes or replaced by an application. It may be used to display the connection progress. |
stream_end(self, _unused)Process </stream:stream> (stream end) tag received from peer. :Parameters: - `_unused`: document created by the parser
|
stream_start(self, doc)Process <stream:stream> (stream start) tag received from peer. :Parameters: - `doc`: document created by the parser
|
write_raw(self, data)Write raw data to the stream socket. :Parameters: - `data`: data to send |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Wed May 31 22:37:00 2006 | http://epydoc.sf.net |