Skip to content

Instantly share code, notes, and snippets.

@tanepiper
Forked from 525c1e21-bd67-4735-ac99-b4b0e5262290/client.js
Created January 22, 2011 15:14
Show Gist options
  • Save tanepiper/791173 to your computer and use it in GitHub Desktop.
Save tanepiper/791173 to your computer and use it in GitHub Desktop.
var frames = 0, last = 0;
setInterval(function () {
if (last) {
var fps = frames / (Date.now() - last) * 1000;
console.log('fps: ' + fps);
}
last = Date.now();
frames = 0;
}, 1000);
var dnode = require('dnode');
dnode({
emit : function (i) { frames ++ }
}).connect(7575);
var dnode = require('dnode');
var EventEmitter = require('events').EventEmitter;
var clients = {};
var tick = function () {
Object.keys(clients).forEach(function (id) {
clients[id].emit(null);
});
process.nextTick(tick);
};
process.nextTick(function() {
tick();
});
dnode(function (client, conn) {
conn.on('ready', function () {
clients[conn.id] = client;
});
conn.on('end', function () {
delete clients[conn.id];
});
}).listen(7575);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment