in reply to PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by xtpu2 (Acolyte) on Apr 09, 2014 at 02:38 UTC | |
by andal (Hermit) on Apr 09, 2014 at 07:40 UTC | |
by Corion (Patriarch) on Apr 09, 2014 at 07:53 UTC | |
by xtpu2 (Acolyte) on Apr 09, 2014 at 14:39 UTC | |
by Corion (Patriarch) on Apr 09, 2014 at 15:41 UTC | |
by xtpu2 (Acolyte) on Apr 09, 2014 at 17:05 UTC | |
|
In Section
Seekers of Perl Wisdom