The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Protocol::XMPP::Stream - handle XMPP protocol stream

VERSION

version 0.005

SYNOPSIS

DESCRIPTION

METHODS

new

Instantiate a stream object. Used for interacting with the underlying XMPP stream.

Takes the following parameters as callbacks:

  • on_queued_write - this will be called whenever there is data queued to be written to the socket

  • on_starttls - this will be called when we want to switch to TLS mode

and the following scalar parameters:

  • user - username (not the full JID, just the first part)

  • pass - password

on_data

Data has been received, pass it over to the SAX parser to trigger any required events.

queue_write

Queue up a write for this stream. Adds to the existing send buffer array if there is one.

When a write is queued, this will send a notification to the on_queued_write callback if one was defined.

write_buffer

Returns the contents of the current write buffer without changing it.

extract_write

Retrieves next pending message from the write buffer and removes it from the list.

ready_to_send

Returns true if there's data ready to be written.

reset

Reset this stream.

Clears out the existing SAX parsing information and sets up a new Protocol::XMPP::Handler ready to accept events. Used when we expect a new <stream> element, for example after authentication or TLS upgrade.

dispatch_event

Call the appropriate event handler.

Currently defined events:

  • features - we have received the features list from the server

  • login - login was completed successfully

  • message - a message was received

  • presence - a presence notification was received

  • subscription - a presence notification was received

  • transfer_request - a file transfer request has been received

  • file - a file was received

preamble

Returns the XML header and opening stream preamble.

jid

Returns the full JID for our user.

If given a parameter, will set the JID to that value, extracting hostname and user by splitting the domain.

user

Username for SASL authentication.

pass

Password for SASL authentication.

hostname

Name of the host

resource

Fragment used to differentiate this client from any other active clients for this user (as defined by bare JID).

write_xml

Write a chunk of XML to the stream, converting from the internal representation to XML text stanzas.

write_text

Write raw text to the output stream.

login

Process the login.

Takes optional named parameters:

  • user - username (not the full JID, just the user part)

  • password - password or passphrase to use in SASL authentication

is_authorised

Returns true if we are authorised already.

is_loggedin

Returns true if we are logged in already.

stream

Override the ->stream method from the base class so that we pick up our own methods directly.

next_id

Returns the next ID in the sequence for outgoing requests.

on_tls_complete

Continues the next part of the connection when TLS is complete.

compose

Compose a new outgoing message.

subscribe

Subscribe to a new contact. Takes a single JID as target.

unsubscribe

Unsubscribe from the given contact. Takes a single JID as target.

authorise

Grant authorisation to the given contact. Takes a single JID as target.

deauthorise

Revokes auth for the given contact. Takes a single JID as target.

AUTHOR

Tom Molesworth <cpan@entitymodel.com>

LICENSE

Copyright Tom Molesworth 2010-2011. Licensed under the same terms as Perl itself.