pull-handshake
easily create a duplex protocol that starts with a handshake
Last updated 10 years ago by dominictarr .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pull-handshake 
SYNC missed versions from official npm registry.

pull-handshake

Create handshakes for binary protocols with pull streams.

Example

var stream = handshake()
var shake = stream.handshake

// Pull some amount of data out of the stream
shake.read(32, function (err, data) {

  // Write a response...
  shake.write(new Buffer('hello there'))

  shake.read(32, function (err, data) {
    // Get a confirmation,
    // and then attach the application
    var stream = createApplicationStream()

    pull(stream, shake.rest(), stream)
    // shake.rest() returns a duplex binary stream.
  })
})


// shake is itself a duplex pull-stream.
pull(shake, stream, shake)

API

handshake([opts], [callback])

opts

Type: Object
Default: {timeout: 5e3}

The allowed duration for the handshake to take place.

callback

Type: Function
Default: function noop () {}

This will be called when the handshake completes, or fails. In the case of failure it is called with an error.

License

MIT

Current Tags

  • 1.1.4                                ...           latest (10 years ago)

12 Versions

  • 1.1.4                                ...           10 years ago
  • 1.1.3                                ...           10 years ago
  • 1.1.2                                ...           10 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.4                                ...           11 years ago
  • 1.0.2                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
  • 0.0.2                                ...           12 years ago
  • 0.0.1                                ...           12 years ago
  • 0.0.0                                ...           12 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (3)

Copyright 2013 - present © cnpmjs.org | Home |