Beispiel #1
0
        private void WriteQueuedSingle(Connection.Packet packet)
        {
            packet.Stream.WriteBool(false);

            packet.Stream.WriteBits((uint)count, 18);
            packet.Stream.Write(data, offset, count);
        }
Beispiel #2
0
 public void Write(Connection.Packet packet)
 {
     if (State == SubchannelState.Queued)
     {
         packet.Stream.WriteBool(true);
         WriteQueued(packet);
     }
     else
     {
         packet.Stream.WriteBool(false);
     }
 }
Beispiel #3
0
        private void WriteQueuedChunk(Connection.Packet packet)
        {
            int chunkOffset = (offset + Connection.BYTES_PER_CHUNK - 1) / Connection.BYTES_PER_CHUNK;
            int chunkCount  = (count + Connection.BYTES_PER_CHUNK - 1) / Connection.BYTES_PER_CHUNK;

            packet.Stream.WriteBits((uint)chunkOffset, 18);
            packet.Stream.WriteBits((uint)chunkCount, 3);

            if (offset == 0)
            {
                packet.Stream.WriteBool(false);
                packet.Stream.WriteBool(false);

                packet.Stream.WriteBits((uint)data.Length, 26);
            }

            packet.Stream.Write(data, offset, count);
        }
Beispiel #4
0
        private void WriteQueued(Connection.Packet packet)
        {
            Preconditions.CheckArgument(State == SubchannelState.Queued);

            if (offset != 0 || count != data.Length)
            {
                packet.Stream.WriteBool(true);
                WriteQueuedChunk(packet);
            }
            else
            {
                packet.Stream.WriteBool(false);
                WriteQueuedSingle(packet);
            }

            SentIn = packet.Seq;
            State  = SubchannelState.Blocked;
        }