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 = Net::XMPP::Message->new();
36
37         Now you can call the creation functions below to populate the tag
38         before sending it.
39

METHODS

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

AUTHOR

253       Originally authored by Ryan Eatmon.
254
255       Previously maintained by Eric Hacker.
256
257       Currently maintained by Darian Anthony Patrick.
258
260       This module is free software, you can redistribute it and/or modify it
261       under the LGPL 2.1.
262
263
264
265perl v5.30.1                      2020-01-30             Net::XMPP::Message(3)
Impressum