Setup another session to handle wheel run, and use $_[SENDER] to reply
back if the client is still connected.

-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/

On Wed, 26 Jan 2005 19:43:15 +0100, Bas A. Schulte
<[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I have a conceptual question about POE and it's sessions that I have
> some trouble with.
> 
> I'm trying to write a POE::Component::Server::TCP server that reads
> command lines from the client (well, not really, in reality it's some
> sort of reference that gets fed to another application on it's command
> line), then needs to execute that command, and respond with feedback
> that the process was started. The new process will run for quite some
> time, whilst the client will disconnect before that.
> 
> In short: clients logs in on some port, says "launch b", then a process
> "launch" is exec-ed using POE::Wheel::RUN, and that child is monitored
> by the main session.
> 
> My simple initial approach was this:
> 
> my $server = new POE::Component::Server::TCP(
>    Alias           => "lala",
>    Port            => 6666,
>    ClientInput     => \&client_input,
> );
> 
> $poe_kernel->run();
> 
> sub client_input
> {
>    my ($input) = @_[ ARG0 ];
> 
>    ...
> 
>    my $child = new POE::Wheel::Run(
> 
>       Program        => $input,  ## Not recommended :)
> 
>       ...
> 
>       StdoutEvent    => 'session_stdout',
> 
>       ...
>    );
> 
>    $heap->{client}->put("Ok, I started $input for you successfully");
> }
> 
> This doesn't work: the 'StdoutEvent' event is posted to the session
> that's running client_input (session created by
> POE::Component::Server::TCP for this connection).
> 
> How am I supposed to handle this?
> 
> Right now, I validate the client input, then put the request to start on
> a queue that I check in another session. This works but it won't report
> back a failure to launch the process to the client. For example, when
> the process to launch is a perl script that fails to compile or
> something.
> 
> Maybe I need to put the request to start on the queue, AND somehow add
> the client session reference to it as well, and respond back from my
> main session instead of directly in client_input?
> 
> I'm somewhat confused right now, hope someone can clear this one up :)
> 
> Thanks in advance,
> 
> Bas.
>

Reply via email to