示例#1
0
        public NetReliableOrderedReceiver(NetConnection connection, int windowSize)
            : base(connection)
        {
            LidgrenException.AssertIsPowerOfTwo((ulong)windowSize, nameof(windowSize));

            _windowSize      = windowSize;
            _earlyReceived   = new NetBitArray(windowSize);
            WithheldMessages = new NetIncomingMessage[windowSize];
        }
        public NetReliableSenderChannel(NetConnection connection, int windowSize)
        {
            LidgrenException.AssertIsPowerOfTwo((ulong)windowSize, nameof(windowSize));

            _connection    = connection;
            _windowSize    = windowSize;
            _windowStart   = 0;
            _sendStart     = 0;
            _receivedAcks  = new NetBitArray(NetConstants.SequenceNumbers);
            StoredMessages = new NetStoredReliableMessage[_windowSize];
            ResendDelay    = connection.ResendDelay;
        }
        public NetUnreliableSenderChannel(NetConnection connection, int windowSize, NetDeliveryMethod method)
        {
            LidgrenException.AssertIsPowerOfTwo((ulong)windowSize, nameof(windowSize));

            _connection   = connection;
            _windowSize   = windowSize;
            _windowStart  = 0;
            _sendStart    = 0;
            _receivedAcks = new NetBitArray(NetConstants.SequenceNumbers);

            _doFlowControl = true;
            if (method == NetDeliveryMethod.Unreliable &&
                connection.Peer.Configuration.SuppressUnreliableUnorderedAcks)
            {
                _doFlowControl = false;
            }
        }
        /// <summary>
        /// Encodes a <see cref="NetBitArray"/> to this buffer.
        /// </summary>
        public static void Write(this IBitBuffer buffer, NetBitArray bitArray)
        {
            buffer.WriteVar(bitArray.Length);

            ReadOnlySpan <uint> values = bitArray.GetBuffer().Span;
            int bitsLeft = NetUtility.PowOf2Mod(bitArray.Length, NetBitArray.BitsPerElement);

            if (bitsLeft == 0)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    buffer.Write(values[i]);
                }
            }
            else
            {
                for (int i = 0; i < values.Length - 1; i++)
                {
                    buffer.Write(values[i]);
                }

                uint last = values[^ 1];
 public ReceivedNormalFragmentGroup(byte[] data, NetBitArray receivedChunks)
 {
     Data           = data;
     ReceivedChunks = receivedChunks;
 }