.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::XMPP::Client 3pm" .TH Net::XMPP::Client 3pm 2024-09-01 "perl v5.40.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Net::XMPP::Client \- XMPP Client Module .SH SYNOPSIS .IX Header "SYNOPSIS" Net::XMPP::Client is a module that provides a developer easy access to the Extensible Messaging and Presence Protocol (XMPP). .SH DESCRIPTION .IX Header "DESCRIPTION" Client.pm uses Protocol.pm to provide enough high level APIs and automation of the low level APIs that writing an XMPP Client 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. .PP Net::XMPP::Client provides functions to connect to an XMPP server, login, send and receive messages, set personal information, create a new user account, manage the roster, and disconnect. You can use all or none of the functions, there is no requirement. .PP For more information on how the details for how Net::XMPP is written please see the help for Net::XMPP itself. .PP For a full list of high level functions available please see Net::XMPP::Protocol. .SS "Basic Functions" .IX Subsection "Basic Functions" .Vb 1 \& use Net::XMPP; \& \& $Con = Net::XMPP::Client\->new(); \& \& $Con\->SetCallbacks(...); \& \& $Con\->Execute(hostname=>"jabber.org", \& username=>"bob", \& password=>"XXXX", \& resource=>"Work" \& ); .Ve .PP For the list of available functions see Net::XMPP::Protocol. .PP .Vb 1 \& $Con\->Disconnect(); .Ve .SH METHODS .IX Header "METHODS" .SH "Basic Functions" .IX Header "Basic Functions" .SS new .IX Subsection "new" .Vb 3 \& new(debuglevel=>0|1|2, \& debugfile=>string, \& debugtime=>0|1) .Ve .PP 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. .SS Connect .IX Subsection "Connect" .Vb 7 \& Connect(hostname=>string, \& port=>integer, \& timeout=>int, \& connectiontype=>string, \& tls=>0|1, \& srv=>0|1, \& componentname=>string) .Ve .PP 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: .PP .Vb 4 \& tcpip standard TCP socket \& http TCP socket, but with the \& headers needed to talk \& through a web proxy .Ve .PP If you specify tls, then it TLS will be used if it is available as a feature. .PP If srv is specified AND Net::DNS is installed and can be loaded, then an SRV query is sent to srv.hostname and the results processed to replace the hostname and port. If the lookup fails, or Net::DNS cannot be loaded, then hostname and port are left alone as the defaults. .PP Alternatively, you may manually specify componentname as the domain portion of the jid and leave hostname set to the actual hostname of the XMPP server. .SS Execute .IX Subsection "Execute" .Vb 12 \& 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) .Ve .PP 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: .PP .Vb 2 \& 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. .Ve .PP 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. .PP If you specify register=>1, then the Client will attempt to register the sepecified account for you, if it does not exist. .SS Process .IX Subsection "Process" .Vb 1 \& Process(integer) .Ve .PP 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. NOTE: This is important for GUIs. You need to leave time to process GUI commands even if you are waiting for packets. The following are the possible return values, and what they mean: .PP .Vb 3 \& 1 \- Status ok, data received. \& 0 \- Status ok, no data received. \& undef \- Status not ok, stop processing. .Ve .PP IMPORTANT: You need to check the output of every Process. If you get an undef then the connection died and you should behave accordingly. .SS Disconnect .IX Subsection "Disconnect" .Vb 1 \& Disconnect() .Ve .PP closes the connection to the server. .SS Connected .IX Subsection "Connected" .Vb 1 \& Connected() .Ve .PP returns 1 if the Transport is connected to the server, and 0 if not. .SH AUTHOR .IX Header "AUTHOR" Originally authored by Ryan Eatmon. .PP Previously maintained by Eric Hacker. .PP Currently maintained by Darian Anthony Patrick. .SH COPYRIGHT .IX Header "COPYRIGHT" This module is free software, you can redistribute it and/or modify it under the LGPL 2.1.