multiplex-stream-muxer
Abstraction on top of multiplex, implementing the abstract-stream-muxer interface
Last updated 11 years ago by daviddias .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install multiplex-stream-muxer 
SYNC missed versions from official npm registry.

multiplex-stream-muxer Node.js Implementation

Abstraction on top of multiplex, implementing the abstract-stream-muxer interface

Usage

multiplex-stream-muxer follows the abstract-stream-muxer API

Example

// Client.js
var MultiplexStreamMuxer = require('multiplex-stream-muxer')

var dialer = new MultiplexStreamMuxer()

var connDialer = dialer.attach(socket, false)

connDialer.dialStream(function (err, stream) {
  t.ifError(err, 'Should not throw')
  t.pass('dialed stream')
})
// Server.js
var MultiplexStreamMuxer = require('multiplex-stream-muxer')

var listener = new MultiplexStreamMuxer()

var connListener = listener.attach(socket, true)

connListener.on('stream', function (stream) {
  t.pass('got stream')
})

You can also follow the net.connect pattern by listening to the ready and error events

var stream = connListener.dialStream()

stream.on('ready', function () {})

stream.on('error', function (err) {})

stream.write('buffer this') // this write will be buffered untill the socket is ready to transmit

Current Tags

  • 0.2.0                                ...           latest (11 years ago)

3 Versions

  • 0.2.0                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |