printastic-protocol

a simple json wire protocol that supports binary file transfers. For talking with printastic servers.

npm install printastic-protocol
4 downloads in the last month

Build Status

printastic-protocol

a simple json wire protocol that supports streaming file transfers.

example


var duplexStream = require('printastic-protocol')();

var client = require('net').connect({port:1111});

client.pipe(duplexStream).pipe(client);


duplexStream.on('message',function(data){
  if(data.type === "file" && duplexStream.authorized()) {
    console.log('got a file');
    var ws = data.stream.pipe(require('fs').createWriteStream('./afile.txt'));
    ws.on('end',function(){
      console.log('saved file');
    });
  } else {
    console.log('got a message',data);
  }
});
npm loves you