From: Dobrica Pavlinusic Date: Tue, 7 Sep 2010 18:38:21 +0000 (+0000) Subject: display presence in web browser X-Git-Url: http://git.rot13.org/?p=MQR.git;a=commitdiff_plain display presence in web browser --- diff --git a/Makefile.PL b/Makefile.PL index 2b84212..06aa8e2 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -17,6 +17,8 @@ requires 'Data::Dump'; requires 'XML::Twig'; requires 'Net::SSLeay'; +requires 'Redis' => 0.20; # I'm too stupid to figure AE::Redis + auto_install; WriteAll; diff --git a/scripts/mqr-httpd.pl b/scripts/mqr-httpd.pl index 25202a9..8bf96c2 100755 --- a/scripts/mqr-httpd.pl +++ b/scripts/mqr-httpd.pl @@ -3,18 +3,41 @@ use common::sense; use AnyEvent; use AnyEvent::HTTPD; +use Data::Dump qw(dump); +use Redis; + + my $cvar = AnyEvent->condvar; my $httpd = AnyEvent::HTTPD->new (port => 19090); $httpd->reg_cb ( '' => sub { - my ($httpd, $req) = @_; - $req->respond ({ content => ['text/html', <<'CONT']}); -

Hello World!

- another test page - -CONT + my ($httpd, $req) = @_; + + my $body = qq{ +

Presence

+ }; + + my $redis = Redis->new; + + my @accounts = $redis->keys( 'presence/*' ); + + warn "# accounts ",dump @accounts; + foreach my $who ( @accounts ) { + $body .= qq{

$who

\n\n}; + } + + $body .= qq{ + + }; + warn $body; + $req->respond ({ content => ['text/html', $body]}); + }, '/test' => sub { my ($httpd, $req) = @_;