1Net::Jabber::Component(U3s)er Contributed Perl DocumentatNieotn::Jabber::Component(3)
2
3
4
6 Net::Jabber::Component - Jabber Component Library
7
9 Net::Jabber::Component is a module that provides a developer easy
10 access to developing server components in the Jabber Instant Messaging
11 protocol.
12
14 Component.pm seeks to provide enough high level APIs and automation of
15 the low level APIs that writing a Jabber Component in Perl is trivial.
16 For those that wish to work with the low level you can do that too,
17 but those functions are covered in the documentation for each module.
18
19 Net::Jabber::Component provides functions to connect to a Jabber
20 server, login, send and receive messages, operate as a server side
21 component, and disconnect. You can use all or none of the functions,
22 there is no requirement.
23
24 For more information on how the details for how Net::Jabber is written
25 please see the help for Net::Jabber itself.
26
27 For a full list of high level functions available please see
28 Net::Jabber::Protocol and Net::XMPP::Protocol.
29
30 Basic Functions
31
32 use Net::Jabber;
33
34 $Con = new Net::Jabber::Component();
35
36 $Con->Execute(hostname=>"jabber.org",
37 componentname=>"service.jabber.org",
38 secret=>"XXXX"
39 );
40
41 #
42 # For the list of available functions see Net::XMPP::Protocol.
43 #
44
45 $Con->Disconnect();
46
48 Basic Functions
49
50 new(debuglevel=>0⎪1⎪2, - creates the Component object. debugfile
51 debugfile=>string, should be set to the path for the debug
52 debugtime=>0⎪1) log to be written. If set to "stdout"
53 then the debug will go there. debuglevel
54 controls the amount of debug. For more
55 information about the valid setting for
56 debuglevel, debugfile, and debugtime see
57 Net::Jabber::Debug.
58
59 AuthSend(secret=>string) - Perform the handshake and authenticate
60 with the server.
61
62 Connect(hostname=>string, - opens a connection to the server
63 port=>integer, based on the value of
64 componentname=>string, connectiontype. The only valid
65 connectiontype=>string) setting is:
66 accept - TCP/IP remote connection
67 In the future this might be used
68 again by offering new features.
69 If accept then it connects to the
70 server listed in the hostname
71 value, on the port listed. The
72 defaults for the two are localhost
73 and 5269.
74
75 Note: A change from previous
76 versions is that Component now
77 shares its core with Client. To
78 that end, the secret should no
79 longer be used. Call AuthSend
80 after connecting. Better yet,
81 use Execute.
82
83 Connected() - returns 1 if the Component is connected to the server,
84 and 0 if not.
85
86 Disconnect() - closes the connection to the server.
87
88 Execute(hostname=>string, - Generic inner loop to handle
89 port=>int, connecting to the server, calling
90 secret=>string, Process, and reconnecting if the
91 componentname=>string, connection is lost. There are four
92 connectiontype=>string, callbacks available that are called
93 connectattempts=>int, at various places in the loop.
94 connectsleep=>int) onconnect - when the component
95 connects to the
96 server.
97 onauth - when the component has
98 completed its handshake
99 with the server this
100 will be called.
101 onprocess - this is the most
102 inner loop and so
103 gets called the most.
104 Be very very careful
105 what you put here
106 since it can
107 *DRASTICALLY* affect
108 performance.
109 ondisconnect - when connection is
110 lost.
111 onexit - when the function gives
112 up trying to connect and
113 exits.
114 The arguments are passed straight
115 on to the Connect function, except
116 for connectattempts and
117 connectsleep. connectattempts is
118 the number of time that the
119 Component should try to connect
120 before giving up. -1 means try
121 forever. The default is -1.
122 connectsleep is the number of
123 seconds to sleep between each
124 connection attempt.
125
126 Process(integer) - takes the timeout period as an argument. If no
127 timeout is listed then the function blocks until
128 a packet is received. Otherwise it waits that
129 number of seconds and then exits so your program
130 can continue doing useful things. NOTE: This is
131 important for GUIs. You need to leave time to
132 process GUI commands even if you are waiting for
133 packets. The following are the possible return
134 values, and what they mean:
135
136 1 - Status ok, data received.
137 0 - Status ok, no data received.
138 undef - Status not ok, stop processing.
139
140 IMPORTANT: You need to check the output of every
141 Process. If you get an undef then the connection
142 died and you should behave accordingly.
143
145 Ryan Eatmon
146
148 This module is free software; you can redistribute it and/or modify it
149 under the same terms as Perl itself.
150
151
152
153perl v5.8.8 2004-08-16 Net::Jabber::Component(3)