1AnyEvent::XMPP::Ext::OOUBs(e3r)Contributed Perl DocumentAantyiEovnent::XMPP::Ext::OOB(3)
2
3
4

NAME

6       AnyEvent::XMPP::Ext::OOB - XEP-0066 Out of Band Data
7

SYNOPSIS

9          my $con = AnyEvent::XMPP::Connection->new (...);
10          $con->add_extension (my $disco = AnyEvent::XMPP::Ext::Disco->new);
11          $con->add_extension (my $oob = AnyEvent::XMPP::Ext::OOB->new);
12          $disco->enable_feature ($oob->disco_feature);
13
14          $oob->reg_cb (oob_recv => sub {
15             my ($oob, $con, $node, $url) = @_;
16
17             if (got ($url)) {
18                $oob->reply_success ($con, $node);
19             } else {
20                $oob->reply_failure ($con, $node, 'not-found');
21             }
22          });
23
24          $oob->send_url (
25             $con, 'someonewho@wants.an.url.com', "http://nakedgirls.com/marie_021.jpg",
26             "Yaww!!! Hot like SUN!",
27             sub {
28                my ($error) = @_;
29                if ($error) { # then error
30                } else { # everything fine
31                }
32             }
33          )
34

DESCRIPTION

36       This module provides a helper abstraction for handling out of band data
37       as specified in XEP-0066.
38
39       The object that is generated handles out of band data requests to and
40       from others.
41
42       There is are also some utility function defined to get for example the
43       oob info from an XML element:
44

FUNCTIONS

46       url_from_node ($node)
47           This function extracts the URL and optionally a description field
48           from the XML element in $node (which must be a
49           AnyEvent::XMPP::Node).
50
51           $node must be the XML node which contains the <url> and optionally
52           <desc> element (which is eg. a <x xmlns='jabber:x:oob'> element)!
53
54           (This method searches both, the jabber:x:oob and jabber:iq:oob
55           namespaces for the <url> and <desc> elements).
56
57           It returns a hash reference which should have following structure:
58
59              {
60                 url  => "http://someurl.org/mycoolparty.jpg",
61                 desc => "That was a party!",
62              }
63
64           If nothing was found this method returns nothing (undef).
65

METHODS

67       new ()
68           This is the constructor, it takes no further arguments.
69
70       reply_success ($con, $node)
71           This method replies to the sender of the oob that the URL was
72           retrieved successfully.
73
74           $con and $node are the $con and $node arguments of the "oob_recv"
75           event you want to reply to.
76
77       reply_failure ($con, $node, $type)
78           This method replies to the sender that either the transfer was
79           rejected or it was not fount.
80
81           If the transfer was rejectes you have to set $type to 'reject',
82           otherwise $type must be 'not-found'.
83
84           $con and $node are the $con and $node arguments of the "oob_recv"
85           event you want to reply to.
86
87       send_url ($con, $jid, $url, $desc, $cb)
88           This method sends a out of band file transfer request to $jid.
89           $url is the URL that the otherone has to download. $desc is an
90           optional description string (human readable) for the file pointed
91           at by the url and can be undef when you don't want to transmit any
92           description.
93
94           $cb is a callback that will be called once the transfer is
95           successful.
96
97           The first argument to the callback will either be undef in case of
98           success or 'reject' when the other side rejected the file or
99           'not-found' if the other side was unable to download the file.
100

EVENTS

102       These events can be registered to whith "reg_cb":
103
104       oob_recv => $con, $node, $url
105           This event is generated whenever someone wants to send you a out of
106           band data file.  $url is a hash reference like it's returned by
107           "url_from_node".
108
109           $con is the AnyEvent::XMPP::Connection (Or
110           AnyEvent::XMPP::IM::Connection) the data was received from.
111
112           $node is the AnyEvent::XMPP::Node of the IQ request, you can get
113           the senders JID from the 'from' attribute of it.
114
115           If you fetched the file successfully you have to call
116           "reply_success".  If you want to reject the file or couldn't get it
117           call "reply_failure".
118
119
120
121perl v5.34.0                      2021-07-22       AnyEvent::XMPP::Ext::OOB(3)
Impressum