Created
August 12, 2011 06:51
-
-
Save t8g/1141594 to your computer and use it in GitHub Desktop.
How to detect server missing in dnode
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
// 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