On Mon, May 31, 2004 at 02:01:38PM +1000, Leigh Sharpe wrote:
> Hi all,
> Is it possible to pass information between states using
> POE::Component::Clinet::Ping?
> What I'm trying to do is ping the same target 5 times in succession, and
> then see if all pings come back in the same order as they left. I need to be
> able to tell, in the got_pong state, which packet has caused the state to be
> called. Under certain network conditoins, packets may come back out of
> order, and I need to know what order they arrived in. The request time isn't
> precise enough to tell.
> Any ideas?
Replace the response event with an arrayref. The first item in the
arrayref should be the response event; the remaining items are "magic
cookie" or other context data you send through the component.
>From the SYNOPSIS:
use POE::Component::Client::Ping ':const';
# post an array ref as the callback to get data back to you
$kernel->post('pinger', 'ping', [ 'pong', @user_data ]);
# use the REQ_USER_ARGS constant to get to your data
sub got_pong {
my ($request, $response) = @_;
my @user_data = @{$reqest}[REQ_USER_ARGS..$#{$request}];
}
The feature isn't documented in the DESCRIPTION. I'll fix that.
-- Rocco Caputo