[Forgot to include the list in the reply.]
As far I know, the code refs you provide to named arguments execute
within the context the Component. If you want object_states, you have
to pass them along to the constructor and then post() to them from
within the Component code refs. If you look at the Client::TCP code
you will see that the code refs you pass in are stored and then called
directly:
...
my $input_callback = delete $param{ServerInput}; # <-- inside new()
...
got_server_input => sub {
my $heap = $_[HEAP];
return if $heap->{shutdown};
$input_callback->(@_); # <-- your ServerInput argument from the constructor
},
HTH,
Nick
On 1/12/07, Bas Schulte <[EMAIL PROTECTED]> wrote:
Hi,
it's been a while since I used POE and have some brain issues getting
to grip with it (once again, heh).
I intend to use POE::Component::Client::TCP to grab some content off
a server and I'd like to use methods calls. Now, when creating the
client I specify a callback for 'Connected'.
How do I make the client call a method (i.e. 'connected' as shown
below) so that I have $self available to call further methods?
I can't figure out how I can do this :(
Anyone refresh my mind again?
package Blah;
sub new
{
...
return ($self);
}
sub grabSome
{
my $self = shift;
my $client = new POE::Component::Client::TCP(
RemoteAddress => '127.0..0.1',
RemotePort => '10000',
Connected => \&??????,
...
)
}
##
## Called by poco client tcp
##
sub connected
{
my ($self, $kernel, $heap, $session) = @_[OBJECT, KERNEL, HEAP,
SESSION];
## got reference to $self, call methods on it:
$self->someOtherMethod();
}
sub someOtherMethod
{
my $self = shift;
...
}