Closed geNAZt closed 11 years ago
hmm, can you describe a concrete example where you would use this?
I'm not sure what you mean by "pipe two Streams that come out of two different Connections matching the stream meta tag", can you try that statement differently?
If i take your example:
var MuxDemux = require('..')
var net = require('net')
var mdm1 = MuxDemux()
var mdm2 =
MuxDemux(function (stream) {
stream.on('data', console.log.bind(console))
})
net.createServer(function (con) {
con.pipe(mdm2).pipe(con)
}).listen(8642, function () {
var con = net.connect(8642)
con.pipe(mdm1).pipe(con)
var ds = mdm1.createWriteStream('times')
setInterval(function () {
ds.write(new Date().toString())
}, 1e3)
})
And then let three Clients( a, b, c ) connect with 3 Streams( a, b and c ) and i want that Client a Stream a pipes to Client c Stream a via Stream piping.
oh, oops! that example is misleading for using more than one stream at a time. Instead, it should be created inside the connection handler.
I have corrected the readme example! sorry!
var MuxDemux = require('mux-demux')
var net = require('net')
net.createServer(function (con) {
con.pipe(MuxDemux(function (stream) {
stream.on('data', console.log.bind(console))
})).pipe(con)
}).listen(8642, function () {
var con = net.connect(8642), mx
con.pipe(mx = MuxDemux).pipe(con)
var ds = mx.createWriteStream('times')
setInterval(function () {
ds.write(new Date().toString())
}, 1e3)
})
with this style it's not necessary to pipe to track the connection, because each connection gets it's own mux-demux.
Ah okay thanks
It would be nice if a Stream has a property which holds a connection identifier, so that i can hold all Streams of a Connection in one Container. The goal is to pipe two Streams that come out of two different Connections matching the stream meta tag.