encodeAsBinary static method

dynamic encodeAsBinary(
  1. dynamic obj
)

Encode packet as 'buffer sequence' by removing blobs, and deconstructing packet into object with placeholders and a list of buffers.

@param {Object} packet @return {Buffer} encoded @api private

Implementation

static encodeAsBinary(obj) {
    final deconstruction = Binary.deconstructPacket(obj);
    final pack = encodeAsString(deconstruction['packet']);
    final buffers = deconstruction['buffers'];

    // add packet info to beginning of data list
    return <dynamic>[pack]..addAll(buffers); // write all the buffers
  }