Example #1
0
        public void SendAll()
        {
            bool   flag = false;
            object obj;

            try
            {
                Monitor.Enter(obj = this._lock, ref flag);
                Utils.Swap <Dictionary <CSteamID, Queue <SteamP2PWriter.WriteInformation> > >(ref this._pendingSendData, ref this._pendingSendDataSwap);
            }
            finally
            {
                if (flag)
                {
                    Monitor.Exit(obj);
                }
            }
            using (Dictionary <CSteamID, Queue <SteamP2PWriter.WriteInformation> > .Enumerator enumerator = this._pendingSendDataSwap.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <CSteamID, Queue <SteamP2PWriter.WriteInformation> > current = enumerator.Current;
                    Queue <SteamP2PWriter.WriteInformation> writeInformationQueue             = current.Value;
                    while (writeInformationQueue.Count > 0)
                    {
                        SteamP2PWriter.WriteInformation writeInformation = writeInformationQueue.Dequeue();
                        SteamNetworking.SendP2PPacket(current.Key, writeInformation.Data, (uint)writeInformation.Size, (EP2PSend)2, this._channel);
                        this._bufferPool.Enqueue(writeInformation.Data);
                    }
                }
            }
        }
 public void SendAll()
 {
     lock (this._lock)
     {
         foreach (KeyValuePair <CSteamID, Queue <SteamP2PWriter.WriteInformation> > _pendingSendDatum in this._pendingSendData)
         {
             Queue <SteamP2PWriter.WriteInformation> value = _pendingSendDatum.Value;
             while (value.Count > 0)
             {
                 SteamP2PWriter.WriteInformation writeInformation = value.Dequeue();
                 bool flag = SteamNetworking.SendP2PPacket(_pendingSendDatum.Key, writeInformation.Data, (uint)writeInformation.Size, EP2PSend.k_EP2PSendReliable, this._channel);
                 this._bufferPool.Enqueue(writeInformation.Data);
             }
         }
     }
 }
Example #3
0
        // Token: 0x06000B59 RID: 2905 RVA: 0x003CDC74 File Offset: 0x003CBE74
        public void QueueSend(CSteamID user, byte[] data, int length)
        {
            object @lock = this._lock;

            lock (@lock)
            {
                Queue <SteamP2PWriter.WriteInformation> queue;
                if (this._pendingSendData.ContainsKey(user))
                {
                    queue = this._pendingSendData[user];
                }
                else
                {
                    queue = (this._pendingSendData[user] = new Queue <SteamP2PWriter.WriteInformation>());
                }
                int i   = length;
                int num = 0;
                while (i > 0)
                {
                    SteamP2PWriter.WriteInformation writeInformation;
                    if (queue.Count == 0 || 1024 - queue.Peek().Size == 0)
                    {
                        if (this._bufferPool.Count > 0)
                        {
                            writeInformation = new SteamP2PWriter.WriteInformation(this._bufferPool.Dequeue());
                        }
                        else
                        {
                            writeInformation = new SteamP2PWriter.WriteInformation();
                        }
                        queue.Enqueue(writeInformation);
                    }
                    else
                    {
                        writeInformation = queue.Peek();
                    }
                    int num2 = Math.Min(i, 1024 - writeInformation.Size);
                    Array.Copy(data, num, writeInformation.Data, writeInformation.Size, num2);
                    writeInformation.Size += num2;
                    i   -= num2;
                    num += num2;
                }
            }
        }
Example #4
0
 public void SendAll()
 {
     lock (this._lock)
         Utils.Swap <Dictionary <CSteamID, Queue <SteamP2PWriter.WriteInformation> > >(ref this._pendingSendData, ref this._pendingSendDataSwap);
     using (Dictionary <CSteamID, Queue <SteamP2PWriter.WriteInformation> > .Enumerator enumerator = this._pendingSendDataSwap.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             KeyValuePair <CSteamID, Queue <SteamP2PWriter.WriteInformation> > current = enumerator.Current;
             Queue <SteamP2PWriter.WriteInformation> writeInformationQueue             = current.Value;
             while (writeInformationQueue.Count > 0)
             {
                 SteamP2PWriter.WriteInformation writeInformation = writeInformationQueue.Dequeue();
                 SteamNetworking.SendP2PPacket(current.Key, writeInformation.Data, (uint)writeInformation.Size, (EP2PSend)2, this._channel);
                 this._bufferPool.Enqueue(writeInformation.Data);
             }
         }
     }
 }
Example #5
0
        // Token: 0x06000B5B RID: 2907 RVA: 0x003CDE44 File Offset: 0x003CC044
        public void SendAll()
        {
            object @lock = this._lock;

            lock (@lock)
            {
                Utils.Swap <Dictionary <CSteamID, Queue <SteamP2PWriter.WriteInformation> > >(ref this._pendingSendData, ref this._pendingSendDataSwap);
            }
            foreach (KeyValuePair <CSteamID, Queue <SteamP2PWriter.WriteInformation> > current in this._pendingSendDataSwap)
            {
                Queue <SteamP2PWriter.WriteInformation> value = current.Value;
                while (value.Count > 0)
                {
                    SteamP2PWriter.WriteInformation writeInformation = value.Dequeue();
                    SteamNetworking.SendP2PPacket(current.Key, writeInformation.Data, (uint)writeInformation.Size, EP2PSend.k_EP2PSendReliable, this._channel);
                    this._bufferPool.Enqueue(writeInformation.Data);
                }
            }
        }
		public void QueueSend(CSteamID user, byte[] data, int length)
		{
			lock (this._lock)
			{
				Queue<SteamP2PWriter.WriteInformation> queue;
				if (this._pendingSendData.ContainsKey(user))
				{
					queue = this._pendingSendData[user];
				}
				else
				{
					queue = (this._pendingSendData[user] = new Queue<SteamP2PWriter.WriteInformation>());
				}
				int i = length;
				int num = 0;
				while (i > 0)
				{
					SteamP2PWriter.WriteInformation writeInformation;
					if (queue.Count == 0 || 1024 - queue.Peek().Size == 0)
					{
						if (this._bufferPool.Count > 0)
						{
							writeInformation = new SteamP2PWriter.WriteInformation(this._bufferPool.Dequeue());
						}
						else
						{
							writeInformation = new SteamP2PWriter.WriteInformation();
						}
						queue.Enqueue(writeInformation);
					}
					else
					{
						writeInformation = queue.Peek();
					}
					int num2 = Math.Min(i, 1024 - writeInformation.Size);
					Array.Copy(data, num, writeInformation.Data, writeInformation.Size, num2);
					writeInformation.Size += num2;
					i -= num2;
					num += num2;
				}
			}
		}
        public void QueueSend(CSteamID user, byte[] data, int length)
        {
            Queue <SteamP2PWriter.WriteInformation> item;

            SteamP2PWriter.WriteInformation writeInformation;
            lock (this._lock)
            {
                if (!this._pendingSendData.ContainsKey(user))
                {
                    Dictionary <CSteamID, Queue <SteamP2PWriter.WriteInformation> > cSteamIDs = this._pendingSendData;
                    Queue <SteamP2PWriter.WriteInformation> writeInformations = new Queue <SteamP2PWriter.WriteInformation>();
                    item            = writeInformations;
                    cSteamIDs[user] = writeInformations;
                }
                else
                {
                    item = this._pendingSendData[user];
                }
                int num  = length;
                int num1 = 0;
                while (num > 0)
                {
                    if (item.Count == 0 || 1024 - item.Peek().Size == 0)
                    {
                        writeInformation = (this._bufferPool.Count <= 0 ? new SteamP2PWriter.WriteInformation() : new SteamP2PWriter.WriteInformation(this._bufferPool.Dequeue()));
                        item.Enqueue(writeInformation);
                    }
                    else
                    {
                        writeInformation = item.Peek();
                    }
                    int num2 = Math.Min(num, 1024 - writeInformation.Size);
                    Array.Copy(data, num1, writeInformation.Data, writeInformation.Size, num2);
                    SteamP2PWriter.WriteInformation size = writeInformation;
                    size.Size = size.Size + num2;
                    num       = num - num2;
                    num1      = num1 + num2;
                }
            }
        }