Skip to content

Instantly share code, notes, and snippets.

@clkao
Created February 27, 2010 08:42
Show Gist options
  • Save clkao/316577 to your computer and use it in GitHub Desktop.
Save clkao/316577 to your computer and use it in GitHub Desktop.
my $bus = AnyMQ->new;
builder {
enable "Static", path => sub { s!^/static/!! }, root => 'static';
enable "Hippie", root => '/_hippie',
init => sub {
my $room = shift;
my $h = shift;
my $sub = $bus->new_listener($h->id);
$sub->subscribe($bus->topic($room));
$sub->poll(sub { $h->send_msg($_[0]) });
},
on_error => sub {
my $room = shift;
# $sub->destroyed(1)
},
on_message => sub {
my $room = shift;
my $msg = shift;
# $msg->{address} = $req->address;
$msg->{time} = time;
$bus->topic($room)->publish($msg);
}
;
$app;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment