The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Analysis::Dispatcher - handle the event stuff for the proto analysers

SYNOPSIS

  use Net::Analysis::Dispatcher;

  my $d = Net::Analysis::Dispatcher->new();
  my $listener = Net::Analysis::Listener::TCP->new();
  $d->add_listener (listener => $listener);

DESCRIPTION

This class is used to register listener objects. Whenever any of the objects emit an event, the dispatcher is used to make sure other interested listeners receive the event.

new ()

Takes no arguments, tells no lies.

add_listener (listener => $obj, config => $hash)

This method adds a new listener to the list of things to be notified of each event.

If the listener object has a field pos, then we attempt to put the listener in that position in the event queue. Valid values are first and last, to receive events first and last. Listener::TCP likes to be first, since it adds extra info to the tcp_packet that other modules might like to see.

If a listener has already claimed the first or last spot, then we croak with an error.

emit_event (name => 'event_name', args => $hash)

The name must be a valid Perl function name. By convention, it should start with the name of the module that is emitting the event (e.g. http_transaction).

Where your code is emitting events, it must must document the args in detail, so that listeners will know what to do with them.

This method runs through the listener list, and if appropriate, invokes the listening method for each listener.

A listener gets the event if it has a method which has the same name as the event_name.

EXPORT

None by default.

SEE ALSO

Net::Analysis::Listener::Base

AUTHOR

Adam B. Worrall, <adam@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Adam B. Worrall

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.

emit_event (name => 'event_name', args => $hash)

The name must be a valid Perl function name. By convention, it should start with the name of the module that is emitting the event (e.g. http_transaction).

Where your code is emitting events, it must must document the args in detail, so that listeners will know what to do with them.

This method runs through the listener list, and if appropriate, invokes the listening method for each listener.

A listener gets the event if it has a method which has the same name as the event_name.