I'm confused about the relationship of KERNEL, HEAP, SESSION on lines 20 and 40
of the sample code below. Is StateA's KERNEL, HEAP, and SESSION at line 20 the
same as the TCP Client's KERNEL, HEAP, and SESSION at line 40?
I'm thoroughly confused about the Inline States provided by the TCP client and
need to know IF and HOW they interact with the caller's state (line 20).
Any help and hints are greatly appreciate.
Gil.Vidals@xxxxxxxxxxxxxxxxxxxx
CEO / PositionResearch.com
1 #-----------------------------------------------------------------------------
2 sub spawn {
3 #-----------------------------------------------------------------------------
4 my $class = shift;
5 POE::Session->create (
6 package_states => [$class => [qw(_start StateA)]],
7 );
8 }
9 #----------------------------------------------------------------------------
10 sub _start
11 #----------------------------------------------------------------------------
12 {
13 my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSION ];
14 ...
15 $kernel->yield(StateB);
16 }
17
18 sub StateA
19 {
20 my ( $kernel, $heap, $session, $url, $port ) = @_[ KERNEL, HEAP, SESSION ];
21
22 $heap->{client} = POE::Component::Client::TCP->new
23 ( RemoteAddress => "127.0.0.1",
24 RemotePort => 23133,
25 ConnectTimeout => 5,
26
27 Started => \&handle_starting, # Optional.
28 Args => [ "arg0", "arg1" ], # Optional. Start args.
29
30 Connected => \&handle_connect,
31 ConnectError => \&handle_connect_error,
32 Disconnected => \&handle_disconnect,
33
34 ServerInput => \&handle_server_input,
35 ServerError => \&handle_server_error,
36 ServerFlushed => \&handle_server_flush,
37
38 InlineStates => {
39 StateTCP => sub {
40 my ( $kernel, $heap, $session ) = @_[KERNEL, HEAP, SESSION];
41 .....
42 },
43 );
44
45 }
|