dispatchAgentRead static method

void dispatchAgentRead(
  1. Channel channel,
  2. Uint8List msg,
  3. ChannelInputCallback handleAgentPacket
)

Implementation

static void dispatchAgentRead(
    Channel channel, Uint8List msg, ChannelInputCallback handleAgentPacket) {
  channel.buf.add(msg);
  while (channel.buf.data.length > 4) {
    SerializableInput input = SerializableInput(channel.buf.data);
    int agentPacketLen = input.getUint32();
    if (input.remaining < agentPacketLen) break;
    handleAgentPacket(
        channel,
        SerializableInput(
            input.viewOffset(input.offset, input.offset + agentPacketLen)));
    channel.buf.flush(agentPacketLen + 4);
  }
}