protocol-buffers-stream
Streaming protocol buffers for Node.js
Last updated 10 years ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install protocol-buffers-stream 
SYNC missed versions from official npm registry.

protocol-buffers-stream

Streaming protocol buffers for Node.js

npm install protocol-buffers-stream

build status

Usage

Assuming you have the following schema

message Test {
  required string hello = 1;
}

Run the following example

var protobufs = require('protocol-buffers-stream')
var fs = require('fs')

var schema = fs.readFileSync('schema.proto')
var createStream = protobufs(schema)

var stream = createStream()

// send a test message
// if your schema message was named example this method would be called example
stream.test({
  hello: 'world'
})

// receive a test message
stream.on('test', function(m) {
  console.log(m)
})

// just pipe to ourselves for testing
stream.pipe(stream)

Encoding

Each buffer is sent using the following encoding

----------------------------------------------
| frame length | message id | message buffer |
----------------------------------------------

The first message sent is a handshake message that contains the message ids of the following messages

If you know that your schema won't change you can pass {handshake:false} to createStream to disable handshaking

License

MIT

Current Tags

  • 1.3.1                                ...           latest (10 years ago)

7 Versions

  • 1.3.1                                ...           10 years ago
  • 1.3.0                                ...           10 years ago
  • 1.2.0                                ...           12 years ago
  • 1.1.1                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |