NAME
Net::Jabber::Component - Jabber Component Library
SYNOPSIS
Net::Jabber::Component is a module that provides a developer easyaccess to developing server components in the Jabber Instant Messagingprotocol.
DESCRIPTION
Component.pm seeks to provide enough high level APIs and automation ofthe low level APIs that writing a Jabber Component in Perl is trivial.For those that wish to work with the low level you can do that too,but those functions are covered in the documentation for each module.Net::Jabber::Component provides functions to connect to a Jabberserver, login, send and receive messages, operate as a server sidecomponent, and disconnect. You can use all or none of the functions,there is no requirement.For more information on how the details for how Net::Jabber is writtenplease see the help for Net::Jabber itself.For a full list of high level functions available please seeNet::Jabber::Protocol and Net::XMPP::Protocol.
Basic Functions
use Net::Jabber;$Con = new Net::Jabber::Component();$Con->Execute(hostname=>"jabber.org",componentname=>"service.jabber.org",secret=>"XXXX");## For the list of available functions see Net::XMPP::Protocol.#$Con->Disconnect();
METHODS
Basic Functions
new(debuglevel=>0|1|2, - creates the Component object. debugfiledebugfile=>string, should be set to the path for the debugdebugtime=>0|1) log to be written. If set to "stdout"then the debug will go there. debuglevelcontrols the amount of debug. For moreinformation about the valid setting fordebuglevel, debugfile, and debugtime seeNet::Jabber::Debug.AuthSend(secret=>string) - Perform the handshake and authenticatewith the server.Connect(hostname=>string, - opens a connection to the serverport=>integer, based on the value ofcomponentname=>string, connectiontype. The only validconnectiontype=>string) setting is:accept - TCP/IP remote connectionIn the future this might be usedagain by offering new features.If accept then it connects to theserver listed in the hostnamevalue, on the port listed. Thedefaults for the two are localhostand 5269.Note: A change from previousversions is that Component nowshares its core with Client. Tothat end, the secret should nolonger be used. Call AuthSendafter connecting. Better yet,use Execute.Connected() - returns 1 if the Component is connected to the server,and 0 if not.Disconnect() - closes the connection to the server.Execute(hostname=>string, - Generic inner loop to handleport=>int, connecting to the server, callingsecret=>string, Process, and reconnecting if thecomponentname=>string, connection is lost. There are fourconnectiontype=>string, callbacks available that are calledconnectattempts=>int, at various places in the loop.connectsleep=>int) onconnect - when the componentconnects to theserver.onauth - when the component hascompleted its handshakewith the server thiswill be called.onprocess - this is the mostinner loop and sogets called the most.Be very very carefulwhat you put heresince it can*DRASTICALLY* affectperformance.ondisconnect - when connection islost.onexit - when the function givesup trying to connect andexits.The arguments are passed straighton to the Connect function, exceptfor connectattempts andconnectsleep. connectattempts isthe number of time that theComponent should try to connectbefore giving up. -1 means tryforever. The default is -1.connectsleep is the number ofseconds to sleep between eachconnection attempt.Process(integer) - takes the timeout period as an argument. If notimeout is listed then the function blocks untila packet is received. Otherwise it waits thatnumber of seconds and then exits so your programcan continue doing useful things. NOTE: This isimportant for GUIs. You need to leave time toprocess GUI commands even if you are waiting forpackets. The following are the possible returnvalues, and what they mean:1 - Status ok, data received.0 - Status ok, no data received.undef - Status not ok, stop processing.IMPORTANT: You need to check the output of everyProcess. If you get an undef then the connectiondied and you should behave accordingly.
AUTHOR
Ryan Eatmon
COPYRIGHT
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.