I tried using IKC::Client first (instead of ClientLite, because I didn't want to use what sounded like a simplified implementation), but couldn't get the Client to actually send an event to the Server. I turned debug on, so I could tell they were connecting, but my client post call failed with "No such process":
$kernel->post( IKC => post => "poe://MissionControl/Commander/do_something" );
I had named the server process 'MissionControl', the session 'Commander', and the event 'do_something'.
Anyways, decided to fall back on ClientLite, since the cookbook example purports to work and is based on that. I now have successful event transmission, but on the server side, ARG0 is empty and SENDER is a complicated structure with no clues as to the identity of the client, so I'm a bit lost now. The cookbook demonstrated that ARG0 contains a list, the second element of which is the client session identifier (named $rsvp), but that example uses the post_respond() function. I'm trying to use the straight post() function, since I don't want an immediate response - I just want to pass events around for now, straight POE style.
Here's the code for both server and client scripts:
[ SERVER CODE ]
#!/usr/bin/perl -w use strict; use Data::Dumper; use POE qw(Component::IKC::Server);
POE::Component::IKC::Server->spawn( port => 1978, name => 'MissionControl', );
POE::Session->create(
inline_states => {
_start => \&start,
do_something => \&do_something,
},
);$poe_kernel->run(); exit( 0 );
sub start
{
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
my $service_name = 'Commander';
$kernel->alias_set( $service_name );
$kernel->call( IKC => publish => $service_name => [ @PUBLISHED_EVENTS ] );
}sub do_something
{
print "SENDER:\n";
print Dumper( $_[ SENDER ] );
print "ARG0:\n";
print Dumper( $_[ ARG0 ] );
}[ CLIENT CODE ]
#!/usr/bin/perl -w use strict; use POE qw(Component::IKC::ClientLite);
my $remote = create_ikc_client( ip => 'localhost', port => 1978, name => "Dude", timeout => 10, );
POE::Session->create(
inline_states => {
_start => \&start,
},
heap => { remote => $remote },
);$poe_kernel->run(); exit( 0 );
sub start
{
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
$heap->{remote}->post( "Commander/ready_to_hunt" );
}[ OUTPUT ]
Here's the output from the server:
SENDER:
$VAR1 = bless( [
{
'from' => undef,
'name' => 'POEComponentIKCResponderThunk00000000'
},
{},
{
'_default' => [
'POE::Component::IKC::Responder::Thunk',
'_default'
],
'_stop' => [
'POE::Component::IKC::Responder::Thunk',
'_stop'
],
'_start' => [
'POE::Component::IKC::Responder::Thunk',
'_start'
]
}
], 'POE::Session' );
ARG0:
$VAR1 = undef;
Help?
-ofer
