From 1a6642d446505560fce108b13b7a618dfeaaf642 Mon Sep 17 00:00:00 2001 From: Greg Smith Date: Thu, 19 Dec 2013 13:09:32 -0500 Subject: [PATCH] fixes #61 --- src/server/cloak/index.js | 3 +++ test/test.js | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/server/cloak/index.js b/src/server/cloak/index.js index 99b09f4..9c26b6d 100644 --- a/src/server/cloak/index.js +++ b/src/server/cloak/index.js @@ -142,6 +142,9 @@ module.exports = (function() { gameLoopInterval = setInterval(function() { var room; + // Pulse lobby + lobby._pulse(); + // Pulse all rooms _(rooms).forEach(function(room) { var oldEnoughToPrune = room.members.length < 1 && new Date().getTime() - room._lastEmpty >= config.pruneEmptyRooms; diff --git a/test/test.js b/test/test.js index 122642a..f9da10d 100644 --- a/test/test.js +++ b/test/test.js @@ -1087,6 +1087,49 @@ module.exports = _.extend(suite, { setTimeout(function() { client2.run(that.host); }, 50); + }, + + pulse: function(test) { + test.expect(20); + + var lobbyPulses = 10; + var roomPulses = 10; + + function checkIfDone() { + if (lobbyPulses === 0 && roomPulses === 0) { + test.done(); + } + } + + var server = this.server; + var client = suite.createClient(); + server.configure({ + port: this.port, + lobby: { + pulse: function() { + lobbyPulses--; + test.ok(true); + checkIfDone(); + } + }, + room: { + pulse: function() { + roomPulses--; + test.ok(true); + checkIfDone(); + } + } + }); + + client.configure({ + serverEvents: { + begin: function() { + server.createRoom(); + } + } + }); + server.run(); + client.run(this.host); } });