protected override void Unpack(BlockBuffer <byte> bytes, Action <byte[]> onUnpacked) { //Because header is int and cost 4 byte while (bytes.WritePosition > 4) { int length = BitConverter.ToInt32(bytes.Buffer, 0); //If receive body if (bytes.WritePosition >= 4 + length) { bytes.MoveReadPostion(4); var data = bytes.Read(length); //Notice unpack finished onUnpacked(data); bytes.ResetIndex(); } } }