Skip to content

Instantly share code, notes, and snippets.

@t8g
Created August 12, 2011 06:51
Show Gist options
  • Save t8g/1141594 to your computer and use it in GitHub Desktop.
Save t8g/1141594 to your computer and use it in GitHub Desktop.
How to detect server missing in dnode
// CLIENT
var dnode = require('dnode');
var EventEmitter = require('events').EventEmitter;
var dnode = new dnode();
dnode.addListener('error', function(err){
console.log('ERREUR ' + err);
});
dnode.connect(5050, function (remote, conn) {
setInterval(function () {
console.log(remote); // Always show { zing: [Function] }, even after server has stop
remote.zing(66, function (n) {
console.log('n = ' + n);
});
}, 1000);
});
// SERVER
var dnode = require('dnode');
var server = dnode({
zing : function (n, cb) { cb(n * 100) }
});
server.listen(5050);
// SCENARIO :
// 1. launch server
// 2. launch client
// 3. kill server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment