Skip to content

Commit

Permalink
Merge remote branch 'bnoordhuis/metrics'
Browse files Browse the repository at this point in the history
Conflicts:
	server/README.md
  • Loading branch information
sork committed Apr 6, 2012
2 parents f580f2f + cfa6f44 commit b49c329
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The game server currently runs on nodejs v0.4.7 (but should run fine on the late
- websocket
- websocket-server
- sanitizer
- memcache
- memcache (only if you want metrics)

All of them can be installed via `npm install -d` (this will install a local copy of all the dependencies in the node_modules directory)

Expand Down
5 changes: 2 additions & 3 deletions server/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function main(config) {
}
};

if(config.metrics_enabled) {
if(metrics) {
metrics.getOpenWorldCount(function(open_world_count) {
// choose the least populated world among open worlds
world = _.min(_.first(worlds, open_world_count), function(w) { return w.playerCount; });
Expand Down Expand Up @@ -78,8 +78,7 @@ function main(config) {
var world = new WorldServer('world'+ (i+1), config.nb_players_per_world, server);
world.run(config.map_filepath);
worlds.push(world);

if(config.metrics_enabled) {
if(metrics) {
world.onPlayerAdded(onPopulationChange);
world.onPlayerRemoved(onPopulationChange);
}
Expand Down
7 changes: 3 additions & 4 deletions server/js/metrics.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

var cls = require("./lib/class"),
_ = require("underscore"),
memcache = require("memcache");
_ = require("underscore");

module.exports = Metrics = Class.extend({
init: function(config) {
var self = this;

this.config = config;
this.client = new memcache.Client(config.memcached_port, config.memcached_host),
this.client = new require("memcache").Client(config.memcached_port, config.memcached_host),
this.client.connect();
this.isReady = false;

Expand Down Expand Up @@ -73,4 +72,4 @@ module.exports = Metrics = Class.extend({
callback(result);
});
}
});
});

0 comments on commit b49c329

Please sign in to comment.