Net::XMPP::Client (3)
Leading comments
Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) Standard preamble: ========================================================================
NAME
Net::XMPP::Client - XMPP Client ModuleSYNOPSIS
Net::XMPP::Client is a module that provides a developer easy access to the Extensible Messaging and Presence Protocol (DESCRIPTION
Client.pm uses Protocol.pm to provide enough high level APIs and automation of the low level APIs that writing anNet::XMPP::Client provides functions to connect to an
For more information on how the details for how Net::XMPP is written please see the help for Net::XMPP itself.
For a full list of high level functions available please see Net::XMPP::Protocol.
Basic Functions
use Net::XMPP; $Con = Net::XMPP::Client->new(); $Con->SetCallbacks(...); $Con->Execute(hostname=>"jabber.org", username=>"bob", password=>"XXXX", resource=>"Work" );
For the list of available functions see Net::XMPP::Protocol.
$Con->Disconnect();
METHODS
Basic Functions
new
new(debuglevel=>0|1|2, debugfile=>string, debugtime=>0|1)
creates the Client object. debugfile should be set to the path for the debug log to be written. If set to ``stdout'' then the debug will go there. debuglevel controls the amount of debug. For more information about the valid setting for debuglevel, debugfile, and debugtime see Net::XMPP::Debug.
Connect
Connect(hostname=>string, port=>integer, timeout=>int, connectiontype=>string, tls=>0|1, srv=>0|1, componentname=>string)
opens a connection to the server listed in the hostname (default localhost), on the port (default 5222) listed, using the connectiontype listed (default tcpip). The two connection types available are:
tcpip standard TCP socket http TCP socket, but with the headers needed to talk through a web proxy
If you specify tls, then it
If srv is specified
Alternatively, you may manually specify componentname as the domain portion of the jid and leave hostname set to the actual hostname of the
Execute
Execute(hostname=>string, port=>int, tls=>0|1, username=>string, password=>string, resource=>string, register=>0|1, connectiontype=>string, connecttimeout=>string, connectattempts=>int, connectsleep=>int, processtimeout=>int)
Generic inner loop to handle connecting to the server, calling Process, and reconnecting if the connection is lost. There are five callbacks available that are called at various places:
onconnect - when the client has made a connection. onauth - when the connection is made and user has been authed. Essentially, this is when you can start doing things as a Client. Like send presence, get your roster, etc... onprocess - this is the most inner loop and so gets called the most. Be very very careful what you put here since it can *DRASTICALLY* affect performance. ondisconnect - when the client disconnects from the server. onexit - when the function gives up trying to connect and exits.
The arguments are passed straight on to the Connect function, except for connectattempts and connectsleep. connectattempts is the number of times that the Component should try to connect before giving up. -1 means try forever. The default is -1. connectsleep is the number of seconds to sleep between each connection attempt.
If you specify register=>1, then the Client will attempt to register the sepecified account for you, if it does not exist.
Process
Process(integer)
takes the timeout period as an argument. If no timeout is listed then the function blocks until a packet is received. Otherwise it waits that number of seconds and then exits so your program can continue doing useful things.
1 - Status ok, data received. 0 - Status ok, no data received. undef - Status not ok, stop processing.
Disconnect
Disconnect()
closes the connection to the server.
Connected
Connected()
returns 1 if the Transport is connected to the server, and 0 if not.
AUTHOR
Originally authored by Ryan Eatmon.Previously maintained by Eric Hacker.
Currently maintained by Darian Anthony Patrick.