Newbie question about sessions

"Artem Harutyunyan" <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
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;
__________________________________________________
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.