G'day xtpu2,
[Disclaimer: I haven't used AnyEvent previously. The following information was gleaned from its (and AnyEvent::Intro's) documentation.]
"It is obvious that $w->recv is the culprit because if I comment out that line, the server works and outputs 'got your message' when I send a message to it. However, in that case the timer doesn't work."
This may only be part of the story, but it might help resolve the AnyEvent issue.
You're calling recv() on a time watcher when it should be called on a condition variable. Also, you'll need a send() method in your timer callback.
Here's a minimal example intended to roughly mirror the AnyEvent part of the code you posted:
#!/usr/bin/env perl -l use strict; use warnings; use AnyEvent; use AnyEvent::Strict; print 'Start at: ', scalar localtime; my $w_cond = AnyEvent->condvar; my $w = AnyEvent->timer( after => 5, cb => sub { print 'Callback: ', scalar localtime; $w_cond->send; } ); $w_cond->recv;
Output:
Start at: Wed Apr 9 12:06:50 2014 Callback: Wed Apr 9 12:06:55 2014
-- Ken
In reply to Re: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by kcott
in thread PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by xtpu2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |