# ``twisted`.`words`.`protocols`.`jabber`.`xmlstream`.`StreamManager``

class documentation

`class StreamManager(XMPPHandlerCollection): (source)`

View In Hierarchy

Business logic representing a managed XMPP connection.

This maintains a single XMPP connection and provides facilities for packet routing and transmission. Business logic modules are objects providing `ijabber.IXMPPHandler` (like subclasses of `XMPPHandler`), and added using `addHandler`.

Method | `__init__` | Undocumented
Method | `addHandler` | Add protocol handler.
Method | `initializationFailed` | Called when stream initialization has failed.
Method | `send` | Send data over the XML stream.
Instance Variable | `factory` | Undocumented
Instance Variable | `logTraffic` | if true, log all traffic.
Instance Variable | `xmlstream` | currently managed XML stream
Method | `_authd` | Called when the stream has been initialized.
Method | `_connected` | Called when the transport connection has been established.
Method | `_disconnected` | Called when the stream has been closed.
Instance Variable | `_initialized` | Whether the stream represented by `xmlstream` has been initialized. This is used when caching outgoing stanzas.
Instance Variable | `_packetQueue` | internal buffer of unsent data. See `send` for details.

Inherited from `XMPPHandlerCollection`:

Method | `__iter__` | Act as a container for handlers.
Method | `removeHandler` | Remove protocol handler.
Instance Variable | `handlers` | List of protocol handlers.

def __init__(self, factory): (source)
overrides `twisted.words.protocols.jabber.xmlstream.XMPPHandlerCollection.__init__`

Undocumented

def addHandler(self, handler): (source)
from `twisted.words.protocols.jabber.ijabber.IXMPPHandlerCollection`
overrides `twisted.words.protocols.jabber.xmlstream.XMPPHandlerCollection.addHandler`

Add protocol handler.

When an XML stream has already been established, the handler's `connectionInitialized` will be called to get it up to speed.

def initializationFailed(self, reason): (source)

Called when stream initialization has failed.

Stream initialization has halted, with the reason indicated by `reason`. It may be retried by calling the authenticator's `initializeStream`. See the respective authenticators for details.

Parameters
reason:`failure.Failure` | A failure instance indicating why stream initialization failed.

def send(self, obj): (source)

Send data over the XML stream.

When there is no established XML stream, the data is queued and sent out when a new XML stream has been established and initialized.

Parameters
obj | data to be sent over the XML stream. See `xmlstream.XmlStream.send` for details.

factory = (source)

Undocumented

logTraffic: `bool` = (source)
if true, log all traffic.
xmlstream: `XmlStream` = (source)
currently managed XML stream
def _authd(self, xs): (source)

Called when the stream has been initialized.

Send out cached stanzas and call each handler's `connectionInitialized` method.

def _connected(self, xs): (source)

Called when the transport connection has been established.

Here we optionally set up traffic logging (depending on `logTraffic`) and call each handler's `makeConnection` method with the `XmlStream` instance.

def _disconnected(self, reason): (source)

Called when the stream has been closed.

From this point on, the manager doesn't interact with the `XmlStream` anymore and notifies each handler that the connection was lost by calling its `connectionLost` method.

_initialized: `bool` = (source)
Whether the stream represented by `xmlstream` has been initialized. This is used when caching outgoing stanzas.
_packetQueue: `list` = (source)
internal buffer of unsent data. See `send` for details.