-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
60 lines (51 loc) · 2.14 KB
/
Program.cs
File metadata and controls
60 lines (51 loc) · 2.14 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
using Serilog;
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
class Program
{
//public static JobQueue MainJobQueue = new JobQueue();
static void Main(string[] args)
{
int processorCount = Environment.ProcessorCount;
ThreadPool.SetMinThreads(processorCount, processorCount);
ThreadPool.SetMaxThreads(processorCount, processorCount);
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.FromLogContext()
.WriteTo.Console()
//.WriteTo.File("logs/lo-.txt", rollingInterval: RollingInterval.Day)
//.WriteTo.Seq("http://localhost:5341/")
.CreateLogger();
Log.Information("로그 기록 시작");
PacketHandler handler = new PacketHandler();
/*GameLogicThread gameLogicThread = new GameLogicThread();
gameLogicThread.Start();*/
GameLogicThread gameLogicThread = GameLogicThread.Instance;
gameLogicThread.Start();
MapManager.Instance.Init();
//gameLogicThread.Enqueue(() => WorldManager.Instance.Update());
DbTransactionWorker.Instance.Start(64, gameLogicThread);
Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listenSocket.Bind(new IPEndPoint(IPAddress.Any, 7777));
//listenSocket.Bind(new IPEndPoint(IPAddress.Parse("192.168.50.221"), 7777));
listenSocket.Listen(1000); //listen: 최대 10개의 대기 큐
Console.WriteLine("실버바인 엔진 서버 시작됨 ( 서버 대기 중...)");
while (true)
{
Socket clientSocket = listenSocket.Accept();
UserSession session = SessionManager.Instance.Generate(clientSocket, gameLogicThread, handler);
if (session != null)
{
session.Start();
Console.WriteLine($"[Accept] SessionID: {session.SessionId} IP: {clientSocket.RemoteEndPoint}");
}
else
{
Console.WriteLine("세션 생성 실패");
clientSocket.Close();
}
}
}
}