Skip to content

Commit

Permalink
we appear to be back up to speed
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwoo committed Apr 13, 2012
1 parent d768450 commit a11f49e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -199,7 +199,7 @@ function fadeOutAllLastSets() {
}
}

function hint(event) {
function requestHint(event) {
socket.emit('hint');
$('#hint').animate({opacity:0});
showPuzzled(me);
Expand Down Expand Up @@ -362,7 +362,7 @@ function setHash(hash) {

function leave(player) {
var update = {};
update[obj.player] = {online: false};
update[player] = {online: false};
updatePlayers(update);
}

Expand Down
11 changes: 6 additions & 5 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a11f49e

Please sign in to comment.