Re: Callback to delay a Server::TCP component?

Mike Schilli <[email protected]> Tue, 20 Apr 2010 09:34:31 -0700 (PDT)
Newsgroups gmane.comp.lang.perl.poe
Message-ID <alpine.LRH.1.00.1004200927560.19219@pyramidlake.greatamerica.corp.yahoo.com>
On Mon, 19 Apr 2010, [email protected] wrote:

> Yeah, I agree that using run_one_timeslice() is a path to insanity,
> ha!

Ha! :)

> What I would recommend is the "tried and true" method of... buffering
> the request?

Yeah, that's the way to go ... although in my case it was even simpler,
as with the protocol I'm using, the server makes the first move (and
a ServerError closes the client connection), so I'm simply dropping
client requests until the server is up:

     sub client_request {
       my ($kernel, $heap, $request) = @_[ KERNEL, HEAP, ARG0 ];

       # discard if server isn't up yet
       return if ! $heap->{client_heap}->{connected};

       # forward to server
       $heap->{client_heap}-> {server}->put( $request );
     }

Thanks!

-- Mike

Mike Schilli
[email protected]