Restructure server code to make embedding easier

This commit is contained in:
Nicholas O'Leary
2013-09-20 17:15:45 +01:00
parent 7348e475eb
commit 0ecbbca7e4
5 changed files with 109 additions and 86 deletions

View File

@@ -66,7 +66,11 @@ var registry = (function() {
events.emit("nodes-stopped");
nodes = {};
},
each: function(cb) {
for (var n in nodes) {
cb(nodes[n]);
}
},
addLogHandler: function(handler) {
logHandlers.push(handler);
}
@@ -132,6 +136,7 @@ util.inherits(Node,EventEmitter);
Node.prototype.close = function() {
// called when a node is removed
this.emit("close");
}
@@ -325,7 +330,7 @@ var parseConfig = function() {
util.log("[red] unknown type: "+activeConfig[i].type);
}
}
// Clean up any orphaned credentials
var deletedCredentials = false;
for (var c in credentials) {