From a11f49eeff501b5f8a8b87dc5f3ebe758c7f7a56 Mon Sep 17 00:00:00 2001 From: Vincent Woo Date: Fri, 13 Apr 2012 09:53:54 -0700 Subject: [PATCH] we appear to be back up to speed --- client/client.js | 8 ++++---- game.js | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/client/client.js b/client/client.js index f48b11e..225b63c 100755 --- a/client/client.js +++ b/client/client.js @@ -6,7 +6,7 @@ var socket , lastMsg , preventRefresh = false , fixwrap - , SERVER_EVENTS = ['init', 'join', 'rejoin', 'taken', 'setHash', 'remaining', 'puzzled', + , SERVER_EVENTS = ['init', 'join', 'leave', 'rejoin', 'taken', 'setHash', 'remaining', 'puzzled', 'add', 'hint', 'start', 'win', 'msg']; $(function() { @@ -40,7 +40,7 @@ function startGame() { socket.on('reconnecting', socket_reconnect); socket.on('reconnect_failed', socket_reconnect_failed); - $('#hint').click(hint); + $('#hint').click(requestHint); $('#input').keydown(input); $('#input').focus(); @@ -199,7 +199,7 @@ function fadeOutAllLastSets() { } } -function hint(event) { +function requestHint(event) { socket.emit('hint'); $('#hint').animate({opacity:0}); showPuzzled(me); @@ -362,7 +362,7 @@ function setHash(hash) { function leave(player) { var update = {}; - update[obj.player] = {online: false}; + update[player] = {online: false}; updatePlayers(update); } diff --git a/game.js b/game.js index c44db12..d0c5af7 100755 --- a/game.js +++ b/game.js @@ -80,6 +80,11 @@ Game.prototype.registerClient = function(socket, sess) { if (this.numPlayers() >= this.players.length) return false; var self = this; + //socket.join(this.hash); + CLIENT_EVENTS.forEach(function(event) { + socket.on(event, self.handleClientMessage(event, socket)); + }); + for (var i = 0; i < this.players.length; i++) { var player = this.players[i]; if (player === null) continue; @@ -95,10 +100,6 @@ Game.prototype.registerClient = function(socket, sess) { return true; } } - //socket.join(this.hash); - CLIENT_EVENTS.forEach(function(event) { - socket.on(event, self.handleClientMessage(event, socket)); - }); var playerIdx = this.firstAvailablePlayerSlot(); this.broadcast('join', playerIdx); @@ -147,7 +148,7 @@ Game.prototype.updateRemaining = function() { } Game.prototype.broadcast = function(event, message) { - console.log(this.hash + ' broadcasting: '); + console.log(this.hash + ' broadcasting event ' + event + ': '); console.log(message); this.players.forEach( function(player) { if (player !== null) player.socket.emit(event, message);