On Mon, Dec 17, 2001 at 04:22:45PM +0100, Jotham Read wrote:
> Hello.  I have a session object (Session) that creates a new child object
> (Child).  Instances of Child need to be able to (in a generic fashion) set
> and recieve alarms.  I see two ways of doing this:
> 
> 1 - Building a timer/alarm set/remove/receive system in Session then passing
> Child a reference to the instance of Session.

POE::Component::Cron would be very nice.  It can be referred to by name:

  POE::Component::Cron->spawn( Alias => 'cron' );

  sub handle_event {
    my $kernel = $_[KERNEL];
    $kernel->post( cron => crontab_add => @fields );  # like cron(8)
    $kernel->post( cron => at_add => @fields );       # like at(1)
    ...;
  }

That interface needs work, but it would be nice.  The last field could
be an event name (posted back) or a sub reference (called back).

> 2 - Have Child produce a new POE::Session within it.

This is not so bad, really, if you take Session's name literally and
consider it a session within POE's event system.  Each Child can have
one, and it acts as the object's interface to POE's features.

There's no reason why you can't do both, except that maybe it's more
than you need.

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net

Reply via email to