Created
February 2, 2010 19:36
-
-
Save hinrik/292943 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Session; | |
use MooseX::POE; | |
use namespace::clean -except => 'meta'; | |
has session_id => ( | |
isa => 'Int', | |
is => 'rw', | |
); | |
sub START { | |
my $id = POE::Kernel->get_active_session->ID; | |
$_[OBJECT]->session_id($id); | |
} | |
package main; | |
use Moose; | |
use POE; | |
POE::Session->create( | |
package_states => [ | |
(__PACKAGE__) => ['_start'], | |
], | |
); | |
POE::Kernel->run; | |
sub _start { | |
my $s = Session->new(); | |
# $s->session_id is still undefined | |
print $s->session_id, "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment