Created
March 6, 2013 07:55
-
-
Save ralphtheninja/5097511 to your computer and use it in GitHub Desktop.
mux-demux and dnode, my brain is boiling and can't see why it's not working
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 MuxDemux = require('mux-demux') | |
var net = require('net') | |
var client = MuxDemux() | |
var d = dnode() | |
d.on('remote', function (remote) { | |
console.log('in remote') | |
remote.foo(function (p) { | |
console.log(p) | |
}) | |
}) | |
client.on('connection', function (c) { | |
console.log('connection' + c.meta) | |
if (c.meta == 'dnode') { | |
d.pipe(c).pipe(d) | |
} | |
}) | |
client.pipe(net.connect(3000)).pipe(client) |
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 d = dnode.connect(3000) | |
d.on('remote', function (remote) { | |
console.log('in remote') | |
remote.foo(function (p) { | |
console.log(p) | |
}) | |
}) |
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 MuxDemux = require('mux-demux') | |
var net = require('net') | |
var server = MuxDemux() | |
var d = dnode({ | |
foo: function (cb) { | |
cb(['bla', 'dude']) | |
} | |
}) | |
d.pipe(server.createStream('dnode')).pipe(d) | |
net.createServer(function (client) { | |
client.pipe(server).pipe(client) | |
}).listen(3000) |
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 d = dnode({ | |
foo: function (cb) { | |
cb(['bla', 'dude']) | |
} | |
}) | |
d.listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
check my gist : https://gist.github.com/nakosung/6044876
pause-stream can be a cure for unpausable mux-demux.