AnyEvent::XMPP::Ext::OOB(3pm) | User Contributed Perl Documentation | AnyEvent::XMPP::Ext::OOB(3pm) |
AnyEvent::XMPP::Ext::OOB - XEP-0066 Out of Band Data
my $con = AnyEvent::XMPP::Connection->new (...); $con->add_extension (my $disco = AnyEvent::XMPP::Ext::Disco->new); $con->add_extension (my $oob = AnyEvent::XMPP::Ext::OOB->new); $disco->enable_feature ($oob->disco_feature); $oob->reg_cb (oob_recv => sub { my ($oob, $con, $node, $url) = @_; if (got ($url)) { $oob->reply_success ($con, $node); } else { $oob->reply_failure ($con, $node, 'not-found'); } }); $oob->send_url ( $con, 'someonewho@wants.an.url.com', "http://nakedgirls.com/marie_021.jpg", "Yaww!!! Hot like SUN!", sub { my ($error) = @_; if ($error) { # then error } else { # everything fine } } )
This module provides a helper abstraction for handling out of band data as specified in XEP-0066.
The object that is generated handles out of band data requests to and from others.
There is are also some utility function defined to get for example the oob info from an XML element:
$node must be the XML node which contains the <url> and optionally <desc> element (which is eg. a <x xmlns='jabber:x:oob'> element)!
(This method searches both, the jabber:x:oob and jabber:iq:oob namespaces for the <url> and <desc> elements).
It returns a hash reference which should have following structure:
{ url => "http://someurl.org/mycoolparty.jpg", desc => "That was a party!", }
If nothing was found this method returns nothing (undef).
$con and $node are the $con and $node arguments of the "oob_recv" event you want to reply to.
If the transfer was rejectes you have to set $type to 'reject', otherwise $type must be 'not-found'.
$con and $node are the $con and $node arguments of the "oob_recv" event you want to reply to.
$cb is a callback that will be called once the transfer is successful.
The first argument to the callback will either be undef in case of success or 'reject' when the other side rejected the file or 'not-found' if the other side was unable to download the file.
These events can be registered to whith "reg_cb":
$con is the AnyEvent::XMPP::Connection (Or AnyEvent::XMPP::IM::Connection) the data was received from.
$node is the AnyEvent::XMPP::Node of the IQ request, you can get the senders JID from the 'from' attribute of it.
If you fetched the file successfully you have to call "reply_success". If you want to reject the file or couldn't get it call "reply_failure".
2022-12-06 | perl v5.36.0 |