Skip to content

Instantly share code, notes, and snippets.

@hinrik
Created February 2, 2010 19:36
Show Gist options
  • Save hinrik/292943 to your computer and use it in GitHub Desktop.
Save hinrik/292943 to your computer and use it in GitHub Desktop.
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