From 078d53cefd8e372e809b5965790d7e96d15f4c40 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Tue, 30 Apr 2013 18:50:03 -0700 Subject: [PATCH] Fix race conditions while joining rooms --- js/client-chat.js | 4 ++-- js/client.js | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/js/client-chat.js b/js/client-chat.js index acad30d58..aa251cbd7 100644 --- a/js/client-chat.js +++ b/js/client-chat.js @@ -127,10 +127,10 @@ if (this.$chatbox) this.$chatbox.focus(); }, join: function() { - this.send('/join '+this.id); + app.send('/join '+this.id); }, leave: function() { - this.send('/leave '+this.id); + app.send('/leave '+this.id); }, receive: function(data) { this.add(data); diff --git a/js/client.js b/js/client.js index 0249af1c8..2d98da427 100644 --- a/js/client.js +++ b/js/client.js @@ -174,7 +174,6 @@ this.user = new User(); this.topbar = new Topbar({el: $('#header')}); - Backbone.history.start({pushState: true}); this.addRoom(''); this.on('init:unsupported', function() { @@ -190,6 +189,7 @@ }); this.initializeConnection(); + Backbone.history.start({pushState: true}); }, /** * Start up the client, including loading teams and preferences, @@ -404,6 +404,13 @@ // Join the lobby. This is necessary for now. // TODO: Revise this later if desired. self.send({room: 'lobby'}, 'join'); + if (self.sendQueue) { + var queue = self.sendQueue; + delete self.sendQueue; + for (var i=0; i