-
Notifications
You must be signed in to change notification settings - Fork 10
/
GatewayConfiguration.cs
129 lines (126 loc) · 4.25 KB
/
GatewayConfiguration.cs
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
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
namespace GatewayBranch.Core.Server
{
/// <summary>
/// Gateway configuration.
/// </summary>
internal class GatewayConfiguration
{
/// <summary>
/// Gets or sets the tcp ports.
/// </summary>
/// <value>
/// The tcp ports.
/// </value>
public List<int> TcpPort { get; set; } = new List<int>();
/// <summary>
/// Gets or sets the udp ports.
/// </summary>
/// <value>
/// The udp ports.
/// </value>
public List<int> UdpPort { get; set; } = new List<int>();
/// <summary>
/// Gets or sets the use libuv.
/// </summary>
/// <value>
/// The use libuv.
/// </value>
public bool UseLibuv { get; set; }
/// <summary>
/// Gets or sets the quiet period seconds.
/// </summary>
/// <value>
/// The quiet period seconds.
/// </value>
public int QuietPeriodSeconds { get; set; } = 1;
public TimeSpan QuietPeriodTimeSpan => TimeSpan.FromSeconds(QuietPeriodSeconds);
/// <summary>
/// Gets or sets the shutdown timeout seconds.
/// </summary>
/// <value>
/// The shutdown timeout seconds.
/// </value>
public int ShutdownTimeoutSeconds { get; set; } = 3;
public TimeSpan ShutdownTimeoutTimeSpan => TimeSpan.FromSeconds(ShutdownTimeoutSeconds);
/// <summary>
/// Gets or sets the so backlog.
/// </summary>
/// <value>
/// The so backlog.
/// </value>
public int SoBacklog { get; set; } = 8192;
/// <summary>
/// Gets or sets the event loop count.
/// </summary>
/// <value>
/// The event loop count.
/// </value>
public int EventLoopCount { get; set; } = Environment.ProcessorCount;
/// <summary>
/// Gets or sets the reader idle time seconds.
/// </summary>
/// <value>
/// The reader idle time seconds.
/// </value>
public int ReaderIdleTimeSeconds { get; set; } = 300;
/// <summary>
/// Gets or sets the writer idle time seconds.
/// </summary>
/// <value>
/// The writer idle time seconds.
/// </value>
public int WriterIdleTimeSeconds { get; set; } = 300;
/// <summary>
/// Gets or sets the all idle time seconds.
/// </summary>
/// <value>
/// The all idle time seconds.
/// </value>
public int AllIdleTimeSeconds { get; set; }
/// <summary>
/// Gets or sets the brabch server reader idle time seconds.
/// </summary>
/// <value>
/// The brabch server reader idle time seconds.
/// </value>
public int BrabchServerReaderIdleTimeSeconds { get; set; } = 300;
/// <summary>
/// Gets or sets the brabch server writer idle time seconds.
/// </summary>
/// <value>
/// The brabch server writer idle time seconds.
/// </value>
public int BrabchServerWriterIdleTimeSeconds { get; set; } = 300;
/// <summary>
/// Gets or sets the brabch server all idle time seconds.
/// </summary>
/// <value>
/// The brabch server all idle time seconds.
/// </value>
public int BrabchServerAllIdleTimeSeconds { get; set; }
/// <summary>
/// Gets or sets the brabch server.
/// </summary>
/// <value>
/// The brabch server.
/// </value>
public List<Server> BrabchServer { get; set; }
internal class Server
{
public string Ip { get; set; }
public int Port { get; set; }
public bool NeedReply { get; set; }
public string MatchId => $"{Ip}:{Port}";
private readonly Lazy<EndPoint> IpAdress;
public EndPoint Host => IpAdress.Value;
public Server()
{
IpAdress = new Lazy<EndPoint>(() => new IPEndPoint(Array.Find(Dns.GetHostEntry(Ip).AddressList, x => x.AddressFamily == AddressFamily.InterNetwork), Port));
}
}
}
}