stream – Stream class handler

XMPP stream

The XMPP stream handling in headstock is performed by the Stream module. This should be considered a private module instanciated by the main client class.

Stream class

class headstock.stream.Stream(jid, password, tls=False, register=False)

A client stream is the interface between a remote XMPP service and the client. It handles the connection and authentication.

jid headstock.protocol.core.jid.JID instance

password account’s password

tls False - flag indicating if the stream runs over a TLS connection

register False - flag indicating if the registration was requested.

ask_roster()
Creates and returns the IQ stanza to query the entity’s roster.
handle_authenticated(e)

Authentication successful

Raises a headstock.error.HeadstockAuthenticationSuccess instance handled by the client.

handle_binding(e)
Handle the JID binding request by returning the full JID.
handle_challenge(e)
Handles the authentication by computing the challenge for the provided credentials.
handle_error(e)

XMPP handler whenever a stream error is returned.

Raises a headstock.error.HeadstockStreamError instance which will be trapped by the client.

handle_features(e)

XMPP handler for stream features.

It will:

  • return immediatly if the element has no children.
  • initiates the TLS negociation (from the stream point

of view) if self.tls is True and the feature has a `<starttls /> child. * initiates the authentication based on the supported mechanisms or abort if none is found.

handle_jid(e)
Parses the bound JID and sets it to the stream.
handle_session(e)

Handles the session elements received by the server.

If the type of the response is result it raises headstock.error.HeadstockAuthenticationSuccess instance handled by the client indicating the session is ready.

Otherwise returns the session stanza indicating the client wishes to start a session.

handle_tls()
Resets the stream header.
notify_presence()
Creates and returns a presence stanza as a bridge.Element instance.
proceed_tls(e)

TLS negociation was successful.

Raises a headstock.error.HeadstockStartTLS instance handled by the client.

stream_header()
Creates and returns a stream header string
terminate()
Creates and returns the closing tag of the stream along with the unavailable presence stanza.

Table Of Contents

Previous topic

register – Register class handler

Next topic

stanza – Stanza helper class

This Page