man POE::Component::Jabber::Client::J2 () - A POE Component for J2 Components

NAME

POE::Component::Jabber::Client::J2 - A POE Component for J2 Components

SYNOPSIS

 use POE qw/ Component::Jabber::Client::J2 Component::Jabber::Error /;
 use POE::Filter::XML::Node;
 use POE::Filter::XML::NS qw/ :JABBER :IQ /;

 POE::Component::Jabber::Client::J2->new(
   IP => 'jabber.server',
   PORT => '5222'
   HOSTNAME => 'jabber.server',
   USERNAME => 'username',
   PASSWORD => 'password',
   BIND_DOMAIN => 'logger',
   BIND_OPTION => 'log',
   ALIAS => 'POCO',
   STATE_PARENT => 'My_Session',
   STATES => {
         INITFINISH => 'My_Init_Finished',
         INPUTEVENT => 'My_Input_Handler',
         ERROREVENT => 'My_Error_Handler',
   }
 );

 $poe_kernel->post('POCO', 'output_handler, $node);
 $poe_kernel->post('POCO', 'return_to_sender', $node);

DESCRIPTION

POE::Component::Jabber::Client::J2 is a simple connection broker to enable communication using the http://jabberd.jabberstudio.org/ns/component/1.0 namespace. All of the steps to initiate the connection, negotiate TLS, negotiate SASL, and binding are all handled for the end developer. Once INITFINISH is fired the developer has a completed J2 component connection for which to send raw XML or even send POE::Filter::XML::Nodes.

METHODS

new()
Accepts many arguments:
IP
The IP address in dotted quad, or the FQDN for the server
PORT
The remote port of the server to connect.
HOSTNAME
The hostname of the server. Used in addressing.
USERNAME
The username to be used in SASL authentication (DIGEST-MD5)
PASSWORD
The password to be used in SASL authentication (DIGEST-MD5)
BIND_DOMAIN
The id to be used on the J2 router
BIND_OPTION #OPTIONAL
The optional child to <bind/> (currently only <log/> and <default/> are accepted by J2)
ALIAS
The alias the component should register for use within POE. Defaults to the class name.
STATE_PARENT
The alias or session id of the session you want the component to contact.
STATES
A hashref containing the event names the component should fire upon finishing initialization and receiving input from the server. INITFINISH, INPUTEVENT, and ERROREVENT must be defined. INITFINISH is fired after connection setup, TLS and SASL negotiation, and resource binding and session establishment take place. ARG0 in INITFINISH will be your jid as a string. ARG0 in INPUTEVENT will be the payload as a POE::Filter::XML::Node. ARG0 in ERROREVENT will be a POE::Component::Jabber::Error See POE::Component::Jabber::Error for possible error types and constants. See POE::Filter::XML and its accompanying documentation to properly manipulate incoming data in your INPUTEVENT, and creation of outbound data.
DEBUG
If bool true, will enable debugging and tracing within the component. All XML sent or received through the component will be printed to STDERR

EVENTS

'output_handler'
This is the event that you use to push data over the wire. Accepts either raw XML or POE::Filter::XML::Nodes.
'return_to_sender'
This event takes (1) a POE::Filter::XML::Node and gives it a unique id, and (2) a return event and places it in the state machine. Upon receipt of response to the request, the return event is fired with the response packet.
'shutdown_socket'
One argument, time in seconds to call shutdown on the underlying Client::TCP
'reconnect_to_server'
This event can take (1) the ip address of a new server and (2) the port. This event may also be called without any arguments and it will force the component to reconnect.

NOTES AND BUGS

This is a connection broker. This should not be considered a first class client. All upper level functions are the responsibility of the end developer.

return_to_sender() no longer overwrites end developer supplied id attributes. Instead, it now checks for a collision, warning and replacing the id, if there is a collision.

AUTHOR

Copyright (c) 2003, 2004, 2005 Nicholas Perez. Distributed under the GPL.