1Net::XMPP::Message(3) User Contributed Perl DocumentationNet::XMPP::Message(3)
2
3
4

NAME

6       Net::XMPP::Message - XMPP Message Module
7

SYNOPSIS

9         Net::XMPP::Message is a companion to the Net::XMPP module.
10         It provides the user a simple interface to set and retrieve all
11         parts of an XMPP Message.
12

DESCRIPTION

14         A Net::XMPP::Message object is passed to the callback function for
15         the message.  Also, the first argument to the callback functions is
16         the session ID from XML::Stream.  There are some cases where you
17         might want thisinformation, like if you created a Client that
18         connects to two servers at once, or for writing a mini server.
19
20           use Net::XMPP;
21
22           sub message {
23             my ($sid,$Mess) = @_;
24             .
25             .
26             .
27           }
28
29         You now have access to all of the retrieval functions available.
30
31         To create a new message to send to the server:
32
33           use Net::XMPP;
34
35           $Mess = new Net::XMPP::Message();
36
37         Now you can call the creation functions below to populate the tag
38         before sending it.
39

METHODS

41       Retrieval functions
42
43         GetTo()      - returns the value in the to='' attribute for the
44         GetTo("jid")   <message/>.  If you specify "jid" as an argument
45                        then a Net::XMPP::JID object is returned and
46                        you can easily parse the parts of the JID.
47
48                        $to    = $Mess->GetTo();
49                        $toJID = $Mess->GetTo("jid");
50
51         GetFrom()      - returns the value in the from='' attribute for the
52         GetFrom("jid")   <message/>.  If you specify "jid" as an argument
53                          then a Net::XMPP::JID object is returned and
54                          you can easily parse the parts of the JID.
55
56                          $from    = $Mess->GetFrom();
57                          $fromJID = $Mess->GetFrom("jid");
58
59         GetType() - returns the type='' attribute of the <message/>.  Each
60                     message is one of four types:
61
62                       normal        regular message (default if type is blank)
63                       chat          one on one chat
64                       groupchat     multi-person chat
65                       headline      headline
66                       error         error message
67
68                     $type = $Mess->GetType();
69
70         GetSubject() - returns the data in the <subject/> tag.
71
72                        $subject = $Mess->GetSubject();
73
74         GetBody() - returns the data in the <body/> tag.
75
76                     $body = $Mess->GetBody();
77
78         GetThread() - returns the data in the <thread/> tag.
79
80                       $thread = $Mess->GetThread();
81
82         GetError() - returns a string with the data of the <error/> tag.
83
84                      $error = $Mess->GetError();
85
86         GetErrorCode() - returns a string with the code='' attribute of the
87                          <error/> tag.
88
89                          $errCode = $Mess->GetErrorCode();
90
91         GetTimeStamp() - returns a string that represents the time this
92                          message object was created (and probably received)
93                          for sending to the client.  If there is a
94                          jabber:x:delay tag then that time is used to show
95                          when the message was sent.
96
97                          $date = $Mess->GetTimeStamp();
98
99       Creation functions
100
101         SetMessage(to=>string⎪JID,    - set multiple fields in the <message/>
102                    from=>string⎪JID,    at one time.  This is a cumulative
103                    type=>string,        and over writing action.  If you set
104                    subject=>string,     the "to" attribute twice, the second
105                    body=>string,        setting is what is used.  If you set
106                    thread=>string,      the subject, and then set the body
107                    errorcode=>string,   then both will be in the <message/>
108                    error=>string)       tag.  For valid settings read the
109                                         specific Set functions below.
110
111                                   $Mess->SetMessage(TO=>"bob\@jabber.org",
112                                                     Subject=>"Lunch",
113                                                     BoDy=>"Let's do lunch!");
114                                   $Mess->SetMessage(to=>"bob\@jabber.org",
115                                                     from=>"jabber.org",
116                                                     errorcode=>404,
117                                                     error=>"Not found");
118
119         SetTo(string) - sets the to='' attribute.  You can either pass
120         SetTo(JID)      a string or a JID object.  They must be valid JIDs
121                         or the server will return an error message.
122                         (ie.  bob@jabber.org/Work)
123
124                         $Mess->SetTo("test\@jabber.org");
125
126         SetFrom(string) - sets the from='' attribute.  You can either pass
127         SetFrom(JID)      a string or a JID object.  They must be valid JIDs
128                           or the server will return an error message. (ie.
129                           jabber:bob@jabber.org/Work) This field is not
130                           required if you are writing a Client since the
131                           server will put the JID of your connection in
132                           there to prevent spamming.
133
134                           $Mess->SetFrom("me\@jabber.org");
135
136         SetType(string) - sets the type attribute.  Valid settings are:
137
138                             normal         regular message (default if blank)
139                             chat           one one one chat style message
140                             groupchat      multi-person chatroom message
141                             headline       news headline, stock ticker, etc...
142                             error          error message
143
144                           $Mess->SetType("groupchat");
145
146         SetSubject(string) - sets the subject of the <message/>.
147
148                              $Mess->SetSubject("This is a test");
149
150         SetBody(string) - sets the body of the <message/>.
151
152                           $Mess->SetBody("To be or not to be...");
153
154         SetThread(string) - sets the thread of the <message/>.  You should
155                             copy this out of the message being replied to so
156                             that the thread is maintained.
157
158                             $Mess->SetThread("AE912B3");
159
160         SetErrorCode(string) - sets the error code of the <message/>.
161
162                                $Mess->SetErrorCode(403);
163
164         SetError(string) - sets the error string of the <message/>.
165
166                            $Mess->SetError("Permission Denied");
167
168         Reply(hash) - creates a new Message object and populates the
169                       to/from, and the subject by putting "re: " in
170                       front.  If you specify a hash the same as with
171                       SetMessage then those values will override the
172                       Reply values.
173
174                       $Reply = $Mess->Reply();
175                       $Reply = $Mess->Reply(type=>"chat");
176
177       Removal functions
178
179         RemoveTo() - removes the to attribute from the <message/>.
180
181                      $Mess->RemoveTo();
182
183         RemoveFrom() - removes the from attribute from the <message/>.
184
185                        $Mess->RemoveFrom();
186
187         RemoveType() - removes the type attribute from the <message/>.
188
189                        $Mess->RemoveType();
190
191         RemoveSubject() - removes the <subject/> element from the
192                           <message/>.
193
194                           $Mess->RemoveSubject();
195
196         RemoveBody() - removes the <body/> element from the
197                        <message/>.
198
199                        $Mess->RemoveBody();
200
201         RemoveThread() - removes the <thread/> element from the <message/>.
202
203                          $Mess->RemoveThread();
204
205         RemoveError() - removes the <error/> element from the <message/>.
206
207                         $Mess->RemoveError();
208
209         RemoveErrorCode() - removes the code attribute from the <error/>
210                             element in the <message/>.
211
212                             $Mess->RemoveErrorCode();
213
214       Test functions
215
216         DefinedTo() - returns 1 if the to attribute is defined in the
217                       <message/>, 0 otherwise.
218
219                       $test = $Mess->DefinedTo();
220
221         DefinedFrom() - returns 1 if the from attribute is defined in the
222                         <message/>, 0 otherwise.
223
224                         $test = $Mess->DefinedFrom();
225
226         DefinedType() - returns 1 if the type attribute is defined in the
227                         <message/>, 0 otherwise.
228
229                         $test = $Mess->DefinedType();
230
231         DefinedSubject() - returns 1 if <subject/> is defined in the
232                            <message/>, 0 otherwise.
233
234                            $test = $Mess->DefinedSubject();
235
236         DefinedBody() - returns 1 if <body/> is defined in the <message/>,
237                         0 otherwise.
238
239                         $test = $Mess->DefinedBody();
240
241         DefinedThread() - returns 1 if <thread/> is defined in the <message/>,
242                           0 otherwise.
243
244                           $test = $Mess->DefinedThread();
245
246         DefinedErrorCode() - returns 1 if <error/> is defined in the
247                              <message/>, 0 otherwise.
248
249                              $test = $Mess->DefinedErrorCode();
250
251         DefinedError() - returns 1 if the code attribute is defined in the
252                          <error/>, 0 otherwise.
253
254                          $test = $Mess->DefinedError();
255

AUTHOR

257       Ryan Eatmon
258
260       This module is free software, you can redistribute it and/or modify it
261       under the LGPL.
262
263
264
265perl v5.8.8                       2007-04-02             Net::XMPP::Message(3)
Impressum