NAME
Net::XMPP2::Event - A event handler class
SYNOPSIS
package foo;
use Net::XMPP2::Event;
our @ISA = qw/Net::XMPP2::Event/;
package main;
my $o = foo->new;
$o->reg_cb (foo => sub { ...; 1 });
$o->event (foo => 1, 2, 3);
DESCRIPTION
This module is just a small helper module for the connection and client classes.
You may only derive from this package.
METHODS
- reg_cb ($eventname1, $cb1, [$eventname2, $cb2, ...])
-
This method registers a callback
$cb1
for the event with the name$eventname1
. You can also pass multiple of these eventname => callback pairs.The return value will be an ID that represents the set of callbacks you have installed. Call
unreg_cb
with that ID to remove those callbacks again.To see a documentation of emitted events please take a look at the EVENTS section in the classes that inherit from this one.
- unreg_cb ($id)
-
Removes the set
$id
of registered callbacks.$id
is the return value of areg_cb
call. - event ($eventname, @args)
-
Emits the event
$eventname
and passes the arguments@args
. - add_forward ($obj, $forward_cb)
-
This method allows to forward or copy all events to a object.
$forward_cb
will be called everytime a event is generated in$self
. The first argument to the callback$forward_cb
will be <$self>, the second will be$obj
, the third will be the event name and the rest will be the event arguments. (For third and rest of argument also see description ofevent
).
AUTHOR
Robin Redeker, <elmex at ta-sa.org>
, JID: <elmex at jabber.org>
COPYRIGHT & LICENSE
Copyright 2007 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.