Permalink
Browse files

we appear to be back up to speed

  • Loading branch information...
vincentwoo committed Apr 13, 2012
1 parent d768450 commit a11f49eeff501b5f8a8b87dc5f3ebe758c7f7a56
Showing with 10 additions and 9 deletions.
  1. +4 −4 client/client.js
  2. +6 −5 game.js
View
@@ -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);
}
View
11 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);

0 comments on commit a11f49e

Please sign in to comment.