-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (44 loc) · 1.49 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (44 loc) · 1.49 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
using System;
namespace ChatServer;
class Program
{
// 실행할 때는 아래 명령어로 실행한다.
//dotnet ChatServer.dll --uniqueID 1 --roomMaxCount 16 --roomMaxUserCount 4 --roomStartNumber 1 --maxUserCount 100
static void Main(string[] args)
{
var serverOption = ParseCommandLine(args);
if(serverOption == null)
{
return;
}
var serverApp = new MainServer();
serverApp.InitConfig(serverOption);
serverApp.CreateStartServer();
MainServer.s_MainLogger.Info("Press q to shut down the server");
// q 키를 누르면 서버를 종료한다.
while (true)
{
System.Threading.Thread.Sleep(50);
if (Console.KeyAvailable)
{
ConsoleKeyInfo key = Console.ReadKey(true);
if (key.KeyChar == 'q')
{
Console.WriteLine("Server Terminate ~~~");
serverApp.StopServer();
break;
}
}
}
}
static ChatServerOption ParseCommandLine(string[] args)
{
var result = CommandLine.Parser.Default.ParseArguments<ChatServerOption>(args) as CommandLine.Parsed<ChatServerOption>;
if (result == null)
{
System.Console.WriteLine("Failed Command Line");
return null;
}
return result.Value;
}
} // end Class