tests/test_sendreceive.js
// helper function to assemble a list of buffers to be passed to dataReceived
helper function to assemble a list of buffers to be passed to dataReceived
helper function to assemble a list of buffers to be passed to dataReceived
function _buildBuffers(arrayOfStrings) {
  var arrayOfBuffers = [];
  var emptyLength = new Buffer(2);
  arrayOfStrings.forEach(function(string) {
    var strLength = new Buffer(2);
    strLength.writeInt16BE(string.length, 0);
    arrayOfBuffers.push(strLength);
    arrayOfBuffers.push(new Buffer(string));
  });
  emptyLength.writeInt16BE(0, 0);
  arrayOfBuffers.push(emptyLength);
  return arrayOfBuffers;
}
function _buildBuffers ( arrayOfStrings ) { var arrayOfBuffers = [ ] ; var emptyLength = new Buffer ( 2 ) ; arrayOfStrings . forEach ( function ( string ) { var strLength = new Buffer ( 2 ) ; strLength . writeInt16BE ( string . length , 0 ) ; arrayOfBuffers . push ( strLength ) ; arrayOfBuffers . push ( new Buffer ( string ) ) ; } ) ; emptyLength . writeInt16BE ( 0 , 0 ) ; arrayOfBuffers . push ( emptyLength ) ; return arrayOfBuffers ; }
helper function to assemble a list of buffers to be passed to dataReceived
helper function to assemble a list of buffers to be passed to dataReceived
// write the length of the string // then write the string