forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionConfig.cs
More file actions
560 lines (498 loc) · 10.6 KB
/
Copy pathConnectionConfig.cs
File metadata and controls
560 lines (498 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
using System;
using System.Collections.Generic;
namespace UnityEngine.Networking
{
[Serializable]
public class ConnectionConfig
{
private const int g_MinPacketSize = 128;
[SerializeField]
private ushort m_PacketSize;
[SerializeField]
private ushort m_FragmentSize;
[SerializeField]
private uint m_ResendTimeout;
[SerializeField]
private uint m_DisconnectTimeout;
[SerializeField]
private uint m_ConnectTimeout;
[SerializeField]
private uint m_MinUpdateTimeout;
[SerializeField]
private uint m_PingTimeout;
[SerializeField]
private uint m_ReducedPingTimeout;
[SerializeField]
private uint m_AllCostTimeout;
[SerializeField]
private byte m_NetworkDropThreshold;
[SerializeField]
private byte m_OverflowDropThreshold;
[SerializeField]
private byte m_MaxConnectionAttempt;
[SerializeField]
private uint m_AckDelay;
[SerializeField]
private uint m_SendDelay;
[SerializeField]
private ushort m_MaxCombinedReliableMessageSize;
[SerializeField]
private ushort m_MaxCombinedReliableMessageCount;
[SerializeField]
private ushort m_MaxSentMessageQueueSize;
[SerializeField]
private ConnectionAcksType m_AcksType;
[SerializeField]
private bool m_UsePlatformSpecificProtocols;
[SerializeField]
private uint m_InitialBandwidth;
[SerializeField]
private float m_BandwidthPeakFactor;
[SerializeField]
private ushort m_WebSocketReceiveBufferMaxSize;
[SerializeField]
private uint m_UdpSocketReceiveBufferMaxSize;
[SerializeField]
private string m_SSLCertFilePath;
[SerializeField]
private string m_SSLPrivateKeyFilePath;
[SerializeField]
private string m_SSLCAFilePath;
[SerializeField]
internal List<ChannelQOS> m_Channels = new List<ChannelQOS>();
public ushort PacketSize
{
get
{
return this.m_PacketSize;
}
set
{
this.m_PacketSize = value;
}
}
public ushort FragmentSize
{
get
{
return this.m_FragmentSize;
}
set
{
this.m_FragmentSize = value;
}
}
public uint ResendTimeout
{
get
{
return this.m_ResendTimeout;
}
set
{
this.m_ResendTimeout = value;
}
}
public uint DisconnectTimeout
{
get
{
return this.m_DisconnectTimeout;
}
set
{
this.m_DisconnectTimeout = value;
}
}
public uint ConnectTimeout
{
get
{
return this.m_ConnectTimeout;
}
set
{
this.m_ConnectTimeout = value;
}
}
public uint MinUpdateTimeout
{
get
{
return this.m_MinUpdateTimeout;
}
set
{
if (value == 0u)
{
throw new ArgumentOutOfRangeException("Minimal update timeout should be > 0");
}
this.m_MinUpdateTimeout = value;
}
}
public uint PingTimeout
{
get
{
return this.m_PingTimeout;
}
set
{
this.m_PingTimeout = value;
}
}
public uint ReducedPingTimeout
{
get
{
return this.m_ReducedPingTimeout;
}
set
{
this.m_ReducedPingTimeout = value;
}
}
public uint AllCostTimeout
{
get
{
return this.m_AllCostTimeout;
}
set
{
this.m_AllCostTimeout = value;
}
}
public byte NetworkDropThreshold
{
get
{
return this.m_NetworkDropThreshold;
}
set
{
this.m_NetworkDropThreshold = value;
}
}
public byte OverflowDropThreshold
{
get
{
return this.m_OverflowDropThreshold;
}
set
{
this.m_OverflowDropThreshold = value;
}
}
public byte MaxConnectionAttempt
{
get
{
return this.m_MaxConnectionAttempt;
}
set
{
this.m_MaxConnectionAttempt = value;
}
}
public uint AckDelay
{
get
{
return this.m_AckDelay;
}
set
{
this.m_AckDelay = value;
}
}
public uint SendDelay
{
get
{
return this.m_SendDelay;
}
set
{
this.m_SendDelay = value;
}
}
public ushort MaxCombinedReliableMessageSize
{
get
{
return this.m_MaxCombinedReliableMessageSize;
}
set
{
this.m_MaxCombinedReliableMessageSize = value;
}
}
public ushort MaxCombinedReliableMessageCount
{
get
{
return this.m_MaxCombinedReliableMessageCount;
}
set
{
this.m_MaxCombinedReliableMessageCount = value;
}
}
public ushort MaxSentMessageQueueSize
{
get
{
return this.m_MaxSentMessageQueueSize;
}
set
{
this.m_MaxSentMessageQueueSize = value;
}
}
public ConnectionAcksType AcksType
{
get
{
return this.m_AcksType;
}
set
{
this.m_AcksType = value;
}
}
[Obsolete("IsAcksLong is deprecated. Use AcksType = ConnectionAcksType.Acks64", false)]
public bool IsAcksLong
{
get
{
return this.m_AcksType != ConnectionAcksType.Acks32;
}
set
{
if (value && this.m_AcksType == ConnectionAcksType.Acks32)
{
this.m_AcksType = ConnectionAcksType.Acks64;
}
else if (!value)
{
this.m_AcksType = ConnectionAcksType.Acks32;
}
}
}
public bool UsePlatformSpecificProtocols
{
get
{
return this.m_UsePlatformSpecificProtocols;
}
set
{
if (value && Application.platform != RuntimePlatform.PS4 && Application.platform != RuntimePlatform.PSP2)
{
throw new ArgumentOutOfRangeException("Platform specific protocols are not supported on this platform");
}
this.m_UsePlatformSpecificProtocols = value;
}
}
public uint InitialBandwidth
{
get
{
return this.m_InitialBandwidth;
}
set
{
this.m_InitialBandwidth = value;
}
}
public float BandwidthPeakFactor
{
get
{
return this.m_BandwidthPeakFactor;
}
set
{
this.m_BandwidthPeakFactor = value;
}
}
public ushort WebSocketReceiveBufferMaxSize
{
get
{
return this.m_WebSocketReceiveBufferMaxSize;
}
set
{
this.m_WebSocketReceiveBufferMaxSize = value;
}
}
public uint UdpSocketReceiveBufferMaxSize
{
get
{
return this.m_UdpSocketReceiveBufferMaxSize;
}
set
{
this.m_UdpSocketReceiveBufferMaxSize = value;
}
}
public string SSLCertFilePath
{
get
{
return this.m_SSLCertFilePath;
}
set
{
this.m_SSLCertFilePath = value;
}
}
public string SSLPrivateKeyFilePath
{
get
{
return this.m_SSLPrivateKeyFilePath;
}
set
{
this.m_SSLPrivateKeyFilePath = value;
}
}
public string SSLCAFilePath
{
get
{
return this.m_SSLCAFilePath;
}
set
{
this.m_SSLCAFilePath = value;
}
}
public int ChannelCount
{
get
{
return this.m_Channels.Count;
}
}
public List<ChannelQOS> Channels
{
get
{
return this.m_Channels;
}
}
public ConnectionConfig()
{
this.m_PacketSize = 1440;
this.m_FragmentSize = 500;
this.m_ResendTimeout = 1200u;
this.m_DisconnectTimeout = 2000u;
this.m_ConnectTimeout = 2000u;
this.m_MinUpdateTimeout = 10u;
this.m_PingTimeout = 500u;
this.m_ReducedPingTimeout = 100u;
this.m_AllCostTimeout = 20u;
this.m_NetworkDropThreshold = 5;
this.m_OverflowDropThreshold = 5;
this.m_MaxConnectionAttempt = 10;
this.m_AckDelay = 33u;
this.m_SendDelay = 10u;
this.m_MaxCombinedReliableMessageSize = 100;
this.m_MaxCombinedReliableMessageCount = 10;
this.m_MaxSentMessageQueueSize = 512;
this.m_AcksType = ConnectionAcksType.Acks32;
this.m_UsePlatformSpecificProtocols = false;
this.m_InitialBandwidth = 0u;
this.m_BandwidthPeakFactor = 2f;
this.m_WebSocketReceiveBufferMaxSize = 0;
this.m_UdpSocketReceiveBufferMaxSize = 0u;
this.m_SSLCertFilePath = null;
this.m_SSLPrivateKeyFilePath = null;
this.m_SSLCAFilePath = null;
}
public ConnectionConfig(ConnectionConfig config)
{
if (config == null)
{
throw new NullReferenceException("config is not defined");
}
this.m_PacketSize = config.m_PacketSize;
this.m_FragmentSize = config.m_FragmentSize;
this.m_ResendTimeout = config.m_ResendTimeout;
this.m_DisconnectTimeout = config.m_DisconnectTimeout;
this.m_ConnectTimeout = config.m_ConnectTimeout;
this.m_MinUpdateTimeout = config.m_MinUpdateTimeout;
this.m_PingTimeout = config.m_PingTimeout;
this.m_ReducedPingTimeout = config.m_ReducedPingTimeout;
this.m_AllCostTimeout = config.m_AllCostTimeout;
this.m_NetworkDropThreshold = config.m_NetworkDropThreshold;
this.m_OverflowDropThreshold = config.m_OverflowDropThreshold;
this.m_MaxConnectionAttempt = config.m_MaxConnectionAttempt;
this.m_AckDelay = config.m_AckDelay;
this.m_SendDelay = config.m_SendDelay;
this.m_MaxCombinedReliableMessageSize = config.MaxCombinedReliableMessageSize;
this.m_MaxCombinedReliableMessageCount = config.m_MaxCombinedReliableMessageCount;
this.m_MaxSentMessageQueueSize = config.m_MaxSentMessageQueueSize;
this.m_AcksType = config.m_AcksType;
this.m_UsePlatformSpecificProtocols = config.m_UsePlatformSpecificProtocols;
this.m_InitialBandwidth = config.m_InitialBandwidth;
if (this.m_InitialBandwidth == 0u)
{
this.m_InitialBandwidth = (uint)(this.m_PacketSize * 1000) / this.m_MinUpdateTimeout;
}
this.m_BandwidthPeakFactor = config.m_BandwidthPeakFactor;
this.m_WebSocketReceiveBufferMaxSize = config.m_WebSocketReceiveBufferMaxSize;
this.m_UdpSocketReceiveBufferMaxSize = config.m_UdpSocketReceiveBufferMaxSize;
this.m_SSLCertFilePath = config.m_SSLCertFilePath;
this.m_SSLPrivateKeyFilePath = config.m_SSLPrivateKeyFilePath;
this.m_SSLCAFilePath = config.m_SSLCAFilePath;
foreach (ChannelQOS current in config.m_Channels)
{
this.m_Channels.Add(new ChannelQOS(current));
}
}
public static void Validate(ConnectionConfig config)
{
if (config.m_PacketSize < 128)
{
throw new ArgumentOutOfRangeException("PacketSize should be > " + 128.ToString());
}
if (config.m_FragmentSize >= config.m_PacketSize - 128)
{
throw new ArgumentOutOfRangeException("FragmentSize should be < PacketSize - " + 128.ToString());
}
if (config.m_Channels.Count > 255)
{
throw new ArgumentOutOfRangeException("Channels number should be less than 256");
}
}
public byte AddChannel(QosType value)
{
if (this.m_Channels.Count > 255)
{
throw new ArgumentOutOfRangeException("Channels Count should be less than 256");
}
if (!Enum.IsDefined(typeof(QosType), value))
{
throw new ArgumentOutOfRangeException("requested qos type doesn't exist: " + (int)value);
}
ChannelQOS item = new ChannelQOS(value);
this.m_Channels.Add(item);
return (byte)(this.m_Channels.Count - 1);
}
public QosType GetChannel(byte idx)
{
if ((int)idx >= this.m_Channels.Count)
{
throw new ArgumentOutOfRangeException("requested index greater than maximum channels count");
}
return this.m_Channels[(int)idx].QOS;
}
}
}