Connecting to the Jabber server
At this stage, we’re ready to connect to the Jabber server. The call to
setup_Jabber() does this for us, returning
a handle to the Jabber connection object that we store in
$jabber. This handle will be used later in the script to send out
<presence/> elements. The $jabber variable contains a reference
to a Net::Jabber::Client object. This is the equivalent
of the con variable used in the earlier Python scripts to
hold the jabber.Client object
and the ConnectionBean
object (cb) in the earlier Java script.[4]
my $jabber = &setup_Jabber(SERVER, PORT, USERNAME, PASSWORD, RESOURCE, $s);
In addition to passing the constants needed for the client connection to
the Jabber server, we pass the initial coffee status, held in
$s. We’ll have a look at what the
setup_Jabber() function does with this initial
status a bit later when we get to the function’s definition.
[4] For the Python scripts, see Section 8.1 and Section 8.3. For the Java script, see Section 8.2.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access