Пример #1
0
        public int Receive(CSteamID user, byte[] buffer, int bufferOffset, int bufferSize)
        {
            uint num1 = 0;

            lock (this._pendingReadBuffers)
            {
                if (!this._pendingReadBuffers.ContainsKey(user))
                {
                    return(0);
                }
                Queue <SteamP2PReader.ReadResult> pendingReadBuffer = this._pendingReadBuffers[user];
                while (pendingReadBuffer.Count > 0)
                {
                    SteamP2PReader.ReadResult readResult = pendingReadBuffer.Peek();
                    uint num2 = Math.Min((uint)bufferSize - num1, readResult.Size - readResult.Offset);
                    if (num2 == 0U)
                    {
                        return((int)num1);
                    }
                    Array.Copy((Array)readResult.Data, (long)readResult.Offset, (Array)buffer, (long)bufferOffset + (long)num1, (long)num2);
                    if ((int)num2 == (int)readResult.Size - (int)readResult.Offset)
                    {
                        this._bufferPool.Enqueue(pendingReadBuffer.Dequeue().Data);
                    }
                    else
                    {
                        readResult.Offset += num2;
                    }
                    num1 += num2;
                }
            }
            return((int)num1);
        }
Пример #2
0
        public int Receive(CSteamID user, byte[] buffer, int bufferOffset, int bufferSize)
        {
            uint num = 0;

            lock (this._pendingReadBuffers)
            {
                if (!this._pendingReadBuffers.ContainsKey(user))
                {
                    return(0);
                }
                Queue <SteamP2PReader.ReadResult> local_1 = this._pendingReadBuffers[user];
                while (local_1.Count > 0)
                {
                    SteamP2PReader.ReadResult local_2 = local_1.Peek();
                    uint local_3 = Math.Min((uint)bufferSize - num, local_2.Size - local_2.Offset);
                    if ((int)local_3 == 0)
                    {
                        return((int)num);
                    }
                    Array.Copy((Array)local_2.Data, (long)local_2.Offset, (Array)buffer, (long)bufferOffset + (long)num, (long)local_3);
                    if ((int)local_3 == (int)local_2.Size - (int)local_2.Offset)
                    {
                        this._bufferPool.Enqueue(local_1.Dequeue().Data);
                    }
                    else
                    {
                        local_2.Offset += local_3;
                    }
                    num += local_3;
                }
            }
            return((int)num);
        }
Пример #3
0
        public int Receive(CSteamID user, byte[] buffer, int bufferOffset, int bufferSize)
        {
            int  num;
            uint num1 = 0;

            lock (this._pendingReadBuffers)
            {
                if (this._pendingReadBuffers.ContainsKey(user))
                {
                    Queue <SteamP2PReader.ReadResult> item = this._pendingReadBuffers[user];
                    while (item.Count > 0)
                    {
                        SteamP2PReader.ReadResult readResult = item.Peek();
                        uint num2 = (uint)Math.Min(bufferSize - num1, readResult.Size - readResult.Offset);
                        if (num2 != 0)
                        {
                            Array.Copy(readResult.Data, (long)readResult.Offset, buffer, (long)((long)bufferOffset + (long)num1), (long)num2);
                            if (num2 != readResult.Size - readResult.Offset)
                            {
                                SteamP2PReader.ReadResult offset = readResult;
                                offset.Offset = offset.Offset + num2;
                            }
                            else
                            {
                                this._bufferPool.Enqueue(item.Dequeue().Data);
                            }
                            num1 = num1 + num2;
                        }
                        else
                        {
                            num = (int)num1;
                            return(num);
                        }
                    }
                    return((int)num1);
                }
                else
                {
                    num = 0;
                }
            }
            return(num);
        }
Пример #4
0
        public int Receive(CSteamID user, byte[] buffer, int bufferOffset, int bufferSize)
        {
            uint num1 = 0;
            bool flag = false;
            Dictionary <CSteamID, Queue <SteamP2PReader.ReadResult> > pendingReadBuffers;

            try
            {
                Monitor.Enter((object)(pendingReadBuffers = this._pendingReadBuffers), ref flag);
                if (!this._pendingReadBuffers.ContainsKey(user))
                {
                    return(0);
                }
                Queue <SteamP2PReader.ReadResult> pendingReadBuffer = this._pendingReadBuffers[user];
                while (pendingReadBuffer.Count > 0)
                {
                    SteamP2PReader.ReadResult readResult = pendingReadBuffer.Peek();
                    uint num2 = Math.Min((uint)bufferSize - num1, readResult.Size - readResult.Offset);
                    if ((int)num2 == 0)
                    {
                        return((int)num1);
                    }
                    Array.Copy((Array)readResult.Data, (long)readResult.Offset, (Array)buffer, (long)bufferOffset + (long)num1, (long)num2);
                    if ((int)num2 == (int)readResult.Size - (int)readResult.Offset)
                    {
                        this._bufferPool.Enqueue(pendingReadBuffer.Dequeue().Data);
                    }
                    else
                    {
                        readResult.Offset += num2;
                    }
                    num1 += num2;
                }
            }
            finally
            {
                if (flag)
                {
                    Monitor.Exit((object)pendingReadBuffers);
                }
            }
            return((int)num1);
        }
Пример #5
0
        // Token: 0x06000B57 RID: 2903 RVA: 0x003CDB3C File Offset: 0x003CBD3C
        public int Receive(CSteamID user, byte[] buffer, int bufferOffset, int bufferSize)
        {
            uint num = 0u;
            Dictionary <CSteamID, Queue <SteamP2PReader.ReadResult> > pendingReadBuffers = this._pendingReadBuffers;

            lock (pendingReadBuffers)
            {
                if (!this._pendingReadBuffers.ContainsKey(user))
                {
                    int result = 0;
                    return(result);
                }
                Queue <SteamP2PReader.ReadResult> queue = this._pendingReadBuffers[user];
                while (queue.Count > 0)
                {
                    SteamP2PReader.ReadResult readResult = queue.Peek();
                    uint num2 = Math.Min((uint)(bufferSize - (int)num), readResult.Size - readResult.Offset);
                    if (num2 == 0u)
                    {
                        int result = (int)num;
                        return(result);
                    }
                    Array.Copy(readResult.Data, (long)((ulong)readResult.Offset), buffer, (long)bufferOffset + (long)((ulong)num), (long)((ulong)num2));
                    if (num2 == readResult.Size - readResult.Offset)
                    {
                        this._bufferPool.Enqueue(queue.Dequeue().Data);
                    }
                    else
                    {
                        readResult.Offset += num2;
                    }
                    num += num2;
                }
            }
            return((int)num);
        }