Hi,
I am trying to create a class based on POE which will handle events
yielded from outside, like this:
use x::TestClass;
my $o = new x::TestClass;
POE::Kernel->run();
POE::Kernel->post ('worker' => 'random');
print "Error: $!\n" if $!;
When I create session in x::TestClass (code of the class is below) I
set an alias to keep it alive, but this does not help. The session
seems to stop before the post() is called (the error is "No such
process").
Could you please tell me how can I keep my session alive ?
Thanks in advance,
Artem.
_________________________________
package x::TestClass;
use strict;
use warnings;
use POE;
sub new
{
my $class = shift;
my $self = {};
bless ($self, $class);
#
# Create POE session
POE::Session->create (
inline_states => {
_start => \&_start,
random => \&random,
_stop => \&_stop,
},
);
return $self;
}
sub _stop
{ print "_stop has been called\n"; }
sub _start
{
print "Alias was set in _start\n" unless POE::Kernel->alias_set ('worker');
}
sub random
{ print "In ".__PACKAGE__." Random\n"; }
1;
__________________________________________________