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


Net-Analysis documentation  | view source Contained in the Net-Analysis distribution.

Index


NAME

Top

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

SYNOPSIS

Top

  use Net::Analysis::Dispatcher;

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

DESCRIPTION

Top

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

Top

Net::Analysis::Listener::Base

AUTHOR

Top

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

COPYRIGHT AND LICENSE

Top

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.


Net-Analysis documentation  | view source Contained in the Net-Analysis distribution.