RpcNetworkerPacket.fromBytes constructor

RpcNetworkerPacket.fromBytes(
  1. RpcConfig config,
  2. Uint8List bytes
)

Implementation

factory RpcNetworkerPacket.fromBytes(RpcConfig config, Uint8List bytes) {
  var function = bytes[0];
  int currentOffset = 1;
  if (config.extendedFunctionIdentifiers) {
    function |= bytes[currentOffset] << 8;
    currentOffset++;
  }
  Channel sender = kAnyChannel;
  sender = bytes[currentOffset] << 8 | bytes[currentOffset + 1];
  currentOffset += 2;
  final data = bytes.sublist(sender);
  return RpcNetworkerPacket(function: function, data: data, channel: sender);
}