in reply to POE Component IKC - Sending session references and coderefs to a foreign kernel

If you ensure the code ref doesn't get freed, all you need is a means of serializing and deserializing the code reference. The following should do the trick (including keeping the code ref alive):

sub submit_request { my ($code_ref, ...) = @_; my $callback_id = "$code_ref"; $registered{ $callback_id } ||= [ 0, $code_ref ]; ++$registered{ $callback_id }[0]; _submit_request($callback_id, @_); }
sub on_response { my $callback_id = shift; my $code_ref = $registered{ $callback_id }[1] or croak(...); --$registered{ $callback_id }[0] or delete( $registered{ $callback_id } ); $code_ref->(@_); }

Assumptions:

Replies are listed 'Best First'.
Re^2: POE Component IKC - Sending session references and coderefs to a foreign kernel
by oscalimero (Initiate) on Jun 25, 2009 at 09:49 UTC
    Thanks for help. I use POCO::IKC::Server with POCO::IKC::Specifier and POCO::IKC::Client with POCOIKC::Responder to solve the issue