in reply to Re^2: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
in thread PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
On another glance
is correct, butmy $w; $w = AnyEvent->timer(
within your timer cb is not what you want. From AnyEvent:$w_cond->send();
You want to ->recv when you are done with things. Adding another timeout timer for example would do the trick allowing your timer to run couple of times and eventually terminating your timer and the main loop after 30 seconds:$w->recv; # enters "main loop" till $condvar gets ->send
my $w; $w = AnyEvent->timer( after => 0, interval => 5, cb => sub { $session->write('5 seconds have passed'); } ); my $timeout_timer; $timeout_timer = AnyEvent->timer( after => 0, interval => 30, cb => sub { undef $w; undef $timeout_timer; $session->write('Timeout after 30 seconds'); $w_cond->send(); } );
|
---|
In Section
Seekers of Perl Wisdom