NAME

Event::Lite::Subscriber - Event listener with callback

SYNOPSIS

use Event::Lite::Subscriber;

my $subscriber = Event::Lite::Subscriber->new(
  address => 'your.server.com',
  port    => 34343,
);

$subscriber->subscribe(
  event     => 'name_of_the_event_to_subscribe_to',
  callback  => sub {
    my $event = shift;
    # This code is executed in a separate process.
    warn "The event named '$event->{event}' has happened";
  },
  
  # The username/password are only necessary if your server requires them:
  username  => 'admin',
  password  => 'swordfish',
);

# Do stuff...
calculate_pi() while 1;

# Finally:
$subscriber->stop();

DESCRIPTION

Event::Lite::Subscriber provides low-level (yet simple) access to events that are broadcast by an Event::Lite::Publisher through a Event::Lite::Server.

NOTE: The subscriber object runs its event loop in a separate process. That means your callback code won't have any effect over variables in the parent process. You also cannot share database handles, open sockets or file handles between the parent process and your callback code.

If this is a limitation you just can't deal with, check out Event::Lite::Subscriber::NoFork because it does not have the same issue (because it does not fork).

SUPPORT

Visit http://www.devstack.com/contact/ or email the author at <jdrago_999@yahoo.com>

Commercial support and installation is available.

AUTHOR

John Drago <jdrago_999@yahoo.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by John Drago

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