Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help

by Anonymous Monk
on Apr 09, 2014 at 14:56 UTC ( #1081658=note: print w/ replies, xml ) Need Help??


in reply to Re: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
in thread PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help

I believe you meant to say:

my $w; sub { ... $w = AnyEvent->timer( ... }
ie: you want $w outside of builder


Comment on Re^2: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
Download Code
Re^3: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by Anonymous Monk on Apr 09, 2014 at 15:23 UTC
    On another glance
    my $w; $w = AnyEvent->timer(
    is correct, but
    $w_cond->send();
    within your timer cb is not what you want. From AnyEvent:
    $w->recv; # enters "main loop" till $condvar gets ->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:
    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(); } );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1081658]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-09-17 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (71 votes), past polls