AnyEvent::XMPP::Extendable - Extendable baseclass


AnyEvent-XMPP documentation Contained in the AnyEvent-XMPP distribution.

Index


Code Index:

NAME

Top

AnyEvent::XMPP::Extendable - Extendable baseclass

DESCRIPTION

Top

This class provides a mechanism to add extensions. Please note that the class that derives from this must also derive from AnyEvent::XMPP::Event!

Please see AnyEvent::XMPP::Ext for more information about this mechanism.

add_extension ($ext)

This method extends the current object with a AnyEvent::XMPP::Ext object. $ext must be an instance of AnyEvent::XMPP::Ext.

Basically add_extension makes the extension an event receiver for all events that the extended object receives.

remove_extension ($ext)

This method removes the extension $ext.

AUTHOR

Top

Robin Redeker, <elmex at ta-sa.org>, JID: <elmex at jabber.org>

COPYRIGHT & LICENSE

Top


AnyEvent-XMPP documentation Contained in the AnyEvent-XMPP distribution.
package AnyEvent::XMPP::Extendable;
no warnings;
use strict;

sub add_extension {
   my ($self, $ext) = @_;
   $self->add_forward ($ext, sub {
      my ($self, $ext, $ev, @args) = @_;
      return if $ext->{inhibit_forward}->{$ev};
      $ext->_event ($ev, $self, @args);
   });
}

sub remove_extension {
   my ($self, $ext) = @_;
   $self->remove_forward ($ext);
}


1; # End of AnyEvent::XMPP