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. | |
Same as `Stream.accept` but assume `self.lock` is acquired. | |
Handle resource binding success. | |
Handle resource binding success. | |
Same as `Stream.close` but assume `self.lock` is acquired. | |
Same as `Stream.connect` but assume `self.lock` is acquired. | |
Initialize stream on outgoing connection. | |
Same as `Stream.disconnect` but assume `self.lock` is acquired. | |
Feed the stream reader with data received. | |
Process incoming <stream:features/> element. | |
Same as `Stream.idle` but assume `self.lock` is acquired. | |
Same as `Stream.loop_iter` but assume `self.lock` is acquired. | |
Create ne `xmlextra.StreamReader` instace as `self._reader`. | |
Create the <features/> element for the stream. | |
Called when connection is authenticated. | |
Called when connection is established. | |
Same as `Stream.process` but assume `self.lock` is acquired. | |
Process first level element of the stream. | |
Process first level stream-namespaced element of the stream. | |
Read data pending on the stream socket and pass it to the parser. | |
Reset `Stream` object state making it ready to handle new connections. | |
Restart the stream as needed after SASL and StartTLS negotiation. | |
Same as `Stream.send` but assume `self.lock` is acquired. | |
Send stream end tag. | |
Send stream error element. | |
Send stream <features/>. | |
Send stream start tag. | |
Write XML `xmlnode` to the stream. | |
Same as `Stream.write_raw` but assume `self.lock` is acquired. | |
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. | |
Same as `Stream.set_response_handlers` but assume `self.lock` is acquired. | |
Inherited from StreamHandler | |
Process complete stanza. | |
Process stream end. | |
Process stream start. |
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 |
_accept(self, sock, myname)Same as `Stream.accept` but assume `self.lock` is acquired. |
_bind_error(self, stanza)Handle resource binding success. [initiating entity only] :raise FatalStreamError: |
_bind_success(self, stanza)Handle resource binding success. [initiating entity only] :Parameters: - `stanza`: <iq type="result"/> stanza received. Set `self.me` to the full JID negotiated. |
_close(self)Same as `Stream.close` but assume `self.lock` is acquired. |
_connect(self, addr, port, service=None, to=None)Same as `Stream.connect` but assume `self.lock` is acquired. |
_connect_socket(self, sock, to=None)Initialize stream on outgoing connection. :Parameters: - `sock`: connected socket for the stream - `to`: name of the remote host |
_disconnect(self)Same as `Stream.disconnect` but assume `self.lock` is acquired. |
_feed_reader(self, data)Feed the stream reader with data received. If `data` is None or empty, then stream end (peer disconnected) is assumed and the stream is closed. :Parameters: - `data`: data received from the stream socket. :Types: - `data`: `unicode` |
_got_features(self)Process incoming <stream:features/> element. [initiating entity only] The received features node is available in `self.features`. |
_idle(self)Same as `Stream.idle` but assume `self.lock` is acquired. |
_loop_iter(self, timeout)Same as `Stream.loop_iter` but assume `self.lock` is acquired. |
_make_reader(self)Create ne `xmlextra.StreamReader` instace as `self._reader`. |
_make_stream_features(self)Create the <features/> element for the stream. [receving entity only] :returns: new <features/> element node. |
_post_auth(self)Called when connection is authenticated. This method is supposed to be overriden in derived classes. |
_post_connect(self)Called when connection is established. This method is supposed to be overriden in derived classes. |
_process(self)Same as `Stream.process` but assume `self.lock` is acquired. |
_process_node(self, xmlnode)Process first level element of the stream. The element may be stream error or features, StartTLS request/response, SASL request/response or a stanza. :Parameters: - `xmlnode`: XML node describing the element |
_process_stream_node(self, xmlnode)Process first level stream-namespaced element of the stream. The element may be stream error or stream features. :Parameters: - `xmlnode`: XML node describing the element |
_read(self)Read data pending on the stream socket and pass it to the parser. |
_reset(self)Reset `Stream` object state making it ready to handle new connections. |
_restart_stream(self)Restart the stream as needed after SASL and StartTLS negotiation. |
_send(self, stanza)Same as `Stream.send` but assume `self.lock` is acquired. |
_send_stream_end(self)Send stream end tag. |
_send_stream_error(self, condition)Send stream error element. :Parameters: - `condition`: stream error condition name, as defined in the XMPP specification. |
_send_stream_features(self)Send stream <features/>. [receiving entity only] |
_send_stream_start(self, sid=None)Send stream start tag. |
_write_node(self, xmlnode)Write XML `xmlnode` to the stream. :Parameters: - `xmlnode`: XML node to send. |
_write_raw(self, data)Same as `Stream.write_raw` but assume `self.lock` is acquired. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Wed May 31 22:37:00 2006 | http://epydoc.sf.net |