Forked from 525c1e21-bd67-4735-ac99-b4b0e5262290/client.js
Created
January 22, 2011 15:14
-
-
Save tanepiper/791173 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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