lib/client/signalflow/websocket_message_parser.js
function parseBinaryDataMessage(msg, data, bigNumberRequested) {
  var offset = extractBinaryFields(msg, binaryDataMessageFormats[msg['version']], data);

  msg.logicalTimestampMs = (msg.timestampMs1 * hiMult) + msg.timestampMs2;
  delete msg.timestampMs1;
  delete msg.timestampMs2;

  if (typeof msg.maxDelayMs1 !== 'undefined' && typeof msg.maxDelayMs2 !== 'undefined') {
    msg.maxDelayMs = (msg.maxDelayMs1 * hiMult) + msg.maxDelayMs2;
    delete msg.maxDelayMs1;
    delete msg.maxDelayMs2;
  }

  var values = [];
  msg.data = values;

  for (var dataPointCount = 0; dataPointCount < msg.count; dataPointCount++) {
    var type = data.getUint8(offset);
    offset++;

    var tsidBytes = [];
    for (var tsidByteIndex = 0; tsidByteIndex < 8; tsidByteIndex++) {
      tsidBytes.push(data.getUint8(offset));
      offset++;
    }
    var tsId = getSnowflakeIdFromUint8Array(tsidBytes);

    var val = null;
    if (type === 0) {
      // NULL_TYPE, nothing to do
    } else if (type === 1) {
      // LONG_TYPE

      // get MSB for twos complement to determine sign
      var isNegative = data.getUint32(offset) >>> 31 > 0;
      if (isNegative) {
        // twos complement manual handling, because we cannot do Int64.
        // must do >>> 0 to prevent bit flips from turning into signed integers.
        val = (new BigNumber(hiMult)
               .times(~data.getUint32(offset) >>> 0)
               .plus(~data.getUint32(offset + 4) >>> 0)
               .plus(1)
               .times(-1));
      } else {
        val = (new BigNumber(data.getUint32(offset))
               .times(hiMult)
               .plus(data.getUint32(offset + 4)));
      }

      if (!bigNumberRequested) {
        val = val.toNumber();
      }
    } else if (type === 2) {
      // DOUBLE_TYPE
      val = data.getFloat64(offset);
      if (bigNumberRequested) {
        val = new BigNumber(val);
      }
    } else if (type === 3) {
      // INT_TYPE
      val = data.getUint32(offset + 4);
      if (bigNumberRequested) {
        val = new BigNumber(val);
      }
    }

    offset += 8;
    values.push({tsId: tsId, value: val});
  }

  delete msg.count;
  return msg;
}
function parseBinaryDataMessage(msg, data, bigNumberRequested) {
  var offset = extractBinaryFields(msg, binaryDataMessageFormats[msg['version']], data);

  msg.logicalTimestampMs = (msg.timestampMs1 * hiMult) + msg.timestampMs2;
  delete msg.timestampMs1;
  delete msg.timestampMs2;

  if (typeof msg.maxDelayMs1 !== 'undefined' && typeof msg.maxDelayMs2 !== 'undefined') {
    msg.maxDelayMs = (msg.maxDelayMs1 * hiMult) + msg.maxDelayMs2;
    delete msg.maxDelayMs1;
    delete msg.maxDelayMs2;
  }

  var values = [];
  msg.data = values;

  for (var dataPointCount = 0; dataPointCount < msg.count; dataPointCount++) {
    var type = data.getUint8(offset);
    offset++;

    var tsidBytes = [];
    for (var tsidByteIndex = 0; tsidByteIndex < 8; tsidByteIndex++) {
      tsidBytes.push(data.getUint8(offset));
      offset++;
    }
    var tsId = getSnowflakeIdFromUint8Array(tsidBytes);

    var val = null;
    if (type === 0) {
      // NULL_TYPE, nothing to do
    } else if (type === 1) {
      // LONG_TYPE

      // get MSB for twos complement to determine sign
      var isNegative = data.getUint32(offset) >>> 31 > 0;
      if (isNegative) {
        // twos complement manual handling, because we cannot do Int64.
        // must do >>> 0 to prevent bit flips from turning into signed integers.
        val = (new BigNumber(hiMult)
               .times(~data.getUint32(offset) >>> 0)
               .plus(~data.getUint32(offset + 4) >>> 0)
               .plus(1)
               .times(-1));
      } else {
        val = (new BigNumber(data.getUint32(offset))
               .times(hiMult)
               .plus(data.getUint32(offset + 4)));
      }

      if (!bigNumberRequested) {
        val = val.toNumber();
      }
    } else if (type === 2) {
      // DOUBLE_TYPE
      val = data.getFloat64(offset);
      if (bigNumberRequested) {
        val = new BigNumber(val);
      }
    } else if (type === 3) {
      // INT_TYPE
      val = data.getUint32(offset + 4);
      if (bigNumberRequested) {
        val = new BigNumber(val);
      }
    }

    offset += 8;
    values.push({tsId: tsId, value: val});
  }

  delete msg.count;
  return msg;
}
function parseBinaryDataMessage ( msg , data , bigNumberRequested ) { var offset = extractBinaryFields ( msg , binaryDataMessageFormats [ msg [ 'version' ] ] , data ) ; msg . logicalTimestampMs = ( msg . timestampMs1 * hiMult ) + msg . timestampMs2 ; delete msg . timestampMs1 ; delete msg . timestampMs2 ; if ( typeof msg . maxDelayMs1 !== 'undefined' && typeof msg . maxDelayMs2 !== 'undefined' ) { msg . maxDelayMs = ( msg . maxDelayMs1 * hiMult ) + msg . maxDelayMs2 ; delete msg . maxDelayMs1 ; delete msg . maxDelayMs2 ; } var values = [ ] ; msg . data = values ; for ( var dataPointCount = 0 ; dataPointCount < msg . count ; dataPointCount ++ ) { var type = data . getUint8 ( offset ) ; offset ++ ; var tsidBytes = [ ] ; for ( var tsidByteIndex = 0 ; tsidByteIndex < 8 ; tsidByteIndex ++ ) { tsidBytes . push ( data . getUint8 ( offset ) ) ; offset ++ ; } var tsId = getSnowflakeIdFromUint8Array ( tsidBytes ) ; var val = null ; if ( type === 0 ) { // NULL_TYPE, nothing to do } else if ( type === 1 ) { // LONG_TYPE // get MSB for twos complement to determine sign var isNegative = data . getUint32 ( offset ) >>> 31 > 0 ; if ( isNegative ) { // twos complement manual handling, because we cannot do Int64. // must do >>> 0 to prevent bit flips from turning into signed integers. val = ( new BigNumber ( hiMult ) . times ( ~ data . getUint32 ( offset ) >>> 0 ) . plus ( ~ data . getUint32 ( offset + 4 ) >>> 0 ) . plus ( 1 ) . times ( - 1 ) ) ; } else { val = ( new BigNumber ( data . getUint32 ( offset ) ) . times ( hiMult ) . plus ( data . getUint32 ( offset + 4 ) ) ) ; } if ( ! bigNumberRequested ) { val = val . toNumber ( ) ; } } else if ( type === 2 ) { // DOUBLE_TYPE val = data . getFloat64 ( offset ) ; if ( bigNumberRequested ) { val = new BigNumber ( val ) ; } } else if ( type === 3 ) { // INT_TYPE val = data . getUint32 ( offset + 4 ) ; if ( bigNumberRequested ) { val = new BigNumber ( val ) ; } } offset += 8 ; values . push ( { tsId : tsId , value : val } ) ; } delete msg . count ; return msg ; }
Parse a binary data message body.

Parse the binary-encoded information and datapoints of a data batch message.
Parse a binary data message body .