acknowlegded streams

make sure everything gets there

readable

var emitter = PeerEmitter(duplexStream);
// Creating a stream need a name for the objects that are sent or// received so you can have multiple streams over the same emitter// as long as they have different names.// Nice names are names of the data types that are transacted.// e.g. you can have a stream of apples, and a stream of orangesvar readStream = emitter.ReadStream('alpha');
// To ack each item, you will need to write it to an ack streamvar ackStream = readStream.AckStream();
readStream.on('data', function(alphas) {
ackStream.write(alphas);
});

writable

var emitter = PeerEmitter(duplexStream);
// creating a stream need a name for the objects that are sent or// received so you can have multiple streams over the same emitter// as long as they have different names.var writeStream = emitter.WriteStream('alpha');
s.pipe(writeStream);
// You also may want to extract an acknowledgement stream for the alpha channelvar ackStream = writeStream.AckStream();
ackStream.on('data', handleAck);
functionhandleAck(o) {
console.log('%j got delivered', o);
}
// if you want acks, you probably want to know if they fail aswellvar timeoutStream = writeStream.TimeoutStream( { timeout:6000 } );
timeoutStream.on('data', handleTimeout);
functionhandleTimeout(o) {
console.log('%j timed out');
}