Net::Ja...mponent(3)

πŸ’– NAME πŸ’–

okay bestie, this is Net::Jabber::Component β€” the Jabber Component Library β€” coming at you from User Contributed Perl Documentation. The page header squishes it into Net::Ja...mponent(3), but the full name is right here. πŸ’…

✨ SYNOPSIS ✨

Net::Jabber::Component is a module that gives a developer easy access to developing server components in the Jabber Instant Messaging protocol. 🫢

🌸 DESCRIPTION 🌸

Component.pm is out here trying to provide enough high level APIs and automation of the low level APIs that writing a Jabber Component in Perl is literally trivial. If you're the kind of dev who wants to work with the low level stuff, you can absolutely do that too β€” those functions are covered in the documentation for each module. πŸ’–

Net::Jabber::Component gives you functions to connect to a Jabber server, login, send and receive messages, operate as a server side component, and disconnect. You can use all of the functions or none of them β€” there is no requirement. No pressure, no cap. ✨

For more information on how the details for how Net::Jabber is written, please see the help for Net::Jabber itself.

For a full list of high level functions available, please see Net::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, debugfile=>string, debugtime=>0|1) β€” creates the Component object. debugfile should be set to the path for the debug log to be written. If it's 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::Jabber::Debug.
  • AuthSend(secret=>string) β€” performs the handshake and authenticates with the server.
  • Connect(hostname=>string, port=>integer, componentname=>string, connectiontype=>string) β€” opens a connection to the server based on the value of connectiontype. The only valid setting is:
    • accept β€” TCP/IP remote connection.

In the future this might be used again by offering new features. If it's accept, then it connects to the server listed in the hostname value, on the port listed. The defaults for the two are localhost and 5269.

Note: a change from previous versions is that Component now shares its core with Client. To that end, the secret should no longer be used. Call AuthSend after 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, port=>int, secret=>string, componentname=>string, connectiontype=>string, connectattempts=>int, connectsleep=>int) β€” generic inner loop to handle connecting to the server, calling Process, and reconnecting if the connection is lost. There are four callbacks available that are called at various places in the loop (the page says four, but then lists five β€” I'm just the messenger 😭):
    • onconnect β€” when the component connects to the server.
    • onauth β€” when the component has completed its handshake with the server, this will be called.
    • 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 connection is lost.
    • 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 time 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.

  • 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. 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:
    • 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 every Process. If you get an undef then the connection died and you should behave accordingly. πŸ’€

🌈 AUTHOR 🌈

Ryan Eatmon

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


kisses and good luck out there, bestie! this was Net::Ja...mponent(3) from User Contributed Perl Documentation, perl v5.42.2, dated 2026-02-15 πŸ«ΆπŸ’–πŸ¦‹

πŸ“¦ where this page comes from