++ed by:

2 non-PAUSE users.

Ryan Eatmon


Net::Jabber::Component - Jabber Component Library


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


  Component.pm seeks to provide enough high level APIs and automation of
  the 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 Jabber 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.

  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

Basic Functions

    use Net::Jabber qw(Component);

    $Con = new Net::Jabber::Component();




    if ($Con->Connected()) {
      print "We are connected to the server...\n";

    $status = $Con->Process();
    $status = $Con->Process(5);

    # For the list of available function see Net::Jabber::Protocol.



Basic Functions

    new(debuglevel=>0|1|2, - creates the Component object.  debugfile
        debugfile=>string,   should be set to the path for the debug
        debugtime=>0|1)      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

    Connect(hostname=>string,       - opens a connection to the server
            port=>integer,            based on the value of connectiontype.
            secret=>string,           The two valid setings are:
            componentname=>string,      accept - TCP/IP remote connection
            connectiontype=>string)              (default)
                                        exec   - STDIN/OUT local connection
                                      If accept then it connects to the
                                      server listed in the hostname value,
                                      on the port listed.  The defaults
                                      for the two are localhost and 5222.
                                      The secret is the password needed
                                      to attach the hostname, and the
                                      componentname is the name that
                                      server and clients will know the
                                      component by (both used for security
                                      If exec then the module reads from
                                      STDIN and writes to STDOUT.  The
                                      server will start the script at run
                                      time and will restart the script if
                                      it exits or dies.  No secret is
                                      needed since this configuration is
                                      specified by the server admin and so
                                      it is assumed that they trust your

    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.

    Execute(hostname=>string,       - Generic inner loop to handle
            port=>int,                connecting to the server, calling
            secret=>string,           Process, and reconnecting if the
            componentname=>string,    connection is lost.  There are four
            connectiontype=>string,   callbacks available that are called
            connectattempts=>int,     at various places in the loop.
            connectsleep=>int)          onconnect - when the component
                                                    connects to the server.
                                        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
                                        ondisconnect - when the connection
                                                       is lost.
                                        onexit - when the function gives
                                                 up trying to connect and
                                      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

    Disconnect() - closes the connection to the server.

    Connected() - returns 1 if the Component is connected to the server,
                  and 0 if not.


By Ryan Eatmon in May of 2000 for http://jabber.org.


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