Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SteamP2PWriter.cs
Go to the documentation of this file.
1using System;
3using Steamworks;
4
6
7public class SteamP2PWriter
8{
9 public class WriteInformation
10 {
11 public byte[] Data;
12
13 public int Size;
14
16 {
17 Data = new byte[1024];
18 Size = 0;
19 }
20
21 public WriteInformation(byte[] data)
22 {
23 Data = data;
24 Size = 0;
25 }
26 }
27
28 private const int BUFFER_SIZE = 1024;
29
31
33
35
36 private int _channel;
37
38 private object _lock = new object();
39
40 public SteamP2PWriter(int channel)
41 {
42 _channel = channel;
43 }
44
45 public void QueueSend(CSteamID user, byte[] data, int length)
46 {
47 //IL_0017: Unknown result type (might be due to invalid IL or missing references)
48 //IL_0034: Unknown result type (might be due to invalid IL or missing references)
49 //IL_0025: Unknown result type (might be due to invalid IL or missing references)
50 lock (_lock)
51 {
53 int num = length;
54 int num2 = 0;
55 while (num > 0)
56 {
58 if (queue2.Count == 0 || 1024 - queue2.Peek().Size == 0)
59 {
60 writeInformation = ((_bufferPool.Count <= 0) ? new WriteInformation() : new WriteInformation(_bufferPool.Dequeue()));
61 queue2.Enqueue(writeInformation);
62 }
63 else
64 {
65 writeInformation = queue2.Peek();
66 }
67 int num3 = Math.Min(num, 1024 - writeInformation.Size);
69 writeInformation.Size += num3;
70 num -= num3;
71 num2 += num3;
72 }
73 }
74 }
75
76 public void ClearUser(CSteamID user)
77 {
78 //IL_0017: Unknown result type (might be due to invalid IL or missing references)
79 //IL_0053: Unknown result type (might be due to invalid IL or missing references)
80 //IL_0025: Unknown result type (might be due to invalid IL or missing references)
81 //IL_0061: Unknown result type (might be due to invalid IL or missing references)
82 lock (_lock)
83 {
85 {
87 while (queue.Count > 0)
88 {
89 _bufferPool.Enqueue(queue.Dequeue().Data);
90 }
91 }
93 {
95 while (queue2.Count > 0)
96 {
97 _bufferPool.Enqueue(queue2.Dequeue().Data);
98 }
99 }
100 }
101 }
102
103 public void SendAll()
104 {
105 //IL_005a: Unknown result type (might be due to invalid IL or missing references)
106 lock (_lock)
107 {
109 }
111 {
113 while (value.Count > 0)
114 {
116 SteamNetworking.SendP2PPacket(item.Key, writeInformation.Data, (uint)writeInformation.Size, (EP2PSend)2, _channel);
118 }
119 }
120 }
121}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static byte Min(byte val1, byte val2)
Definition Math.cs:912
void QueueSend(CSteamID user, byte[] data, int length)
Dictionary< CSteamID, Queue< WriteInformation > > _pendingSendData
Dictionary< CSteamID, Queue< WriteInformation > > _pendingSendDataSwap