Permalink
Browse files

added iq_xml override possibility and doc.

also fixed a small possible bug in handling roster sets.
  • Loading branch information...
1 parent 317360e commit d9582105aefe211a869cf257336cda8d69a50a23 @elmex elmex committed Feb 14, 2009
Showing with 32 additions and 3 deletions.
  1. +4 −0 Changes
  2. +24 −1 lib/AnyEvent/XMPP/Connection.pm
  3. +4 −2 lib/AnyEvent/XMPP/IM/Connection.pm
View
@@ -23,6 +23,10 @@ Revision history for Net-XMPP2
they can be registered to an ::Ext::Disco extension to display
support for certain features.
- xmpp_datetime_as_timestamp fixed w.r.t. UTC based timestamps.
+ - added possibility to override iq_xml events, and documented
+ how to overtake handling of message, presence and iq stanzas.
+ - added patch from Pedro Melo to give stanzas sent by a ::Component
+ the right namespace.
0.3 Mon Jan 28 23:00:58 CET 2009
- fixed a bug in disconnect error reporting.
@@ -300,6 +300,7 @@ sub new {
AnyEvent::XMPP::Error->new (text => 'tls_error: tls negotiation failed')
);
},
+ iq_xml => sub { shift @_; $self->handle_iq (@_) }
);
if ($self->{whitespace_ping_interval} > 0) {
@@ -434,7 +435,6 @@ sub handle_stanza {
} elsif ($node->eq ($def_ns => 'iq')) {
$self->event (iq_xml => $node);
- $self->handle_iq ($node);
} elsif ($node->eq ($def_ns => 'message')) {
$self->event (message_xml => $node);
@@ -1160,16 +1160,39 @@ Here is an example:
This event is sent when a presence stanza is received. C<$node> is the
L<AnyEvent::XMPP::Node> object that represents the <presence> tag.
+If you want to overtake the handling of the stanza, see C<iq_xml>
+below.
+
=item message_xml => $node
This event is sent when a message stanza is received. C<$node> is the
L<AnyEvent::XMPP::Node> object that represents the <message> tag.
+If you want to overtake the handling of the stanza, see C<iq_xml>
+below.
+
=item iq_xml => $node
This event is emitted when a iq stanza arrives. C<$node> is the
L<AnyEvent::XMPP::Node> object that represents the <iq> tag.
+If you want to overtake the handling of a stanza, you should
+register a callback for the C<before_iq_xml> event and call the
+C<stop_event> method. See also L<Object::Event>. This is an example:
+
+ $con->reg_cb (before_iq_xml => sub {
+ my ($con, $node) = @_;
+
+ if (...) {
+ # and stop_event will stop internal handling of the stanza:
+ $con->stop_event;
+ }
+ });
+
+Please note that if you overtake handling of a stanza none of the internal
+handling of that stanza will be done. That means you won't get events
+like C<iq_set_request_xml> anymore.
+
=item iq_set_request_xml => $node
=item iq_get_request_xml => $node
@@ -205,13 +205,15 @@ sub get_roster {
}
sub handle_iq_set {
- my ($self, $node, $rhandled) = @_;
+ my ($self, $node) = @_;
if ($node->find_all ([qw/roster query/])) {
$self->store_roster ($node);
$self->reply_iq_result ($node);
- $$rhandled = 1
+ return 1;
}
+
+ return 0;
}
sub handle_presence {

0 comments on commit d958210

Please sign in to comment.