Skip to content
Browse files

rename session param to client_id. MXHR doesn't really require client…

…-id for now
  • Loading branch information...
1 parent 54aa5ea commit 1754a5c630101fa2f73e2e8fa68c5bcd575da5b2 @miyagawa committed
Showing with 8 additions and 9 deletions.
  1. +6 −7 eg/chat/app.psgi
  2. +2 −2 eg/chat/templates/chat.html
View
13 eg/chat/app.psgi
@@ -13,10 +13,10 @@ use Tatsumaki::MessageQueue;
sub get {
my($self, $channel) = @_;
my $mq = Tatsumaki::MessageQueue->instance($channel);
- my $session = $self->request->param('session')
- or Tatsumaki::Error::HTTP->throw(500, "'session' needed");
- $session = rand(1) if $session eq 'dummy'; # for benchmarking stuff
- $mq->poll_once($session, sub { $self->on_new_event(@_) });
+ my $client_id = $self->request->param('client_id')
+ or Tatsumaki::Error::HTTP->throw(500, "'client_id' needed");
+ $client_id = rand(1) if $client_id eq 'dummy'; # for benchmarking stuff
+ $mq->poll_once($client_id, sub { $self->on_new_event(@_) });
}
sub on_new_event {
@@ -32,13 +32,12 @@ __PACKAGE__->asynchronous(1);
sub get {
my($self, $channel) = @_;
- my $session = $self->request->param('session')
- or Tatsumaki::Error::HTTP->throw(500, "'session' needed");
+ my $client_id = $self->request->param('client_id') || rand(1);
$self->multipart_xhr_push(1);
my $mq = Tatsumaki::MessageQueue->instance($channel);
- $mq->poll($session, sub {
+ $mq->poll($client_id, sub {
my @events = @_;
for my $event (@events) {
$self->stream_write($event);
View
4 eg/chat/templates/chat.html
@@ -69,10 +69,10 @@
var event = eval('(' + payload + ')');
onNewEvent(event);
});
- s.load('/chat/<%= $channel %>/mxhrpoll?session=' + Math.random());
+ s.load('/chat/<%= $channel %>/mxhrpoll');
} else {
$.ev.handlers.message = onNewEvent;
- $.ev.loop('/chat/<%= $channel %>/poll?session=' + Math.random());
+ $.ev.loop('/chat/<%= $channel %>/poll?client_id=' + Math.random());
}
if ($.cookie(cookieName))

0 comments on commit 1754a5c

Please sign in to comment.
Something went wrong with that request. Please try again.