feat : 나중 구조적 통합을 위해 main쪽 비동기 로직으로 변경

This commit is contained in:
qornwh1
2026-03-02 17:47:03 +09:00
parent 961973ff8b
commit 66d18cd0ac
2 changed files with 19 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ namespace MMOserver;
class Program
{
private static void Main()
private static async Task Main()
{
// .MinimumLevel.Warning() // Warning 이상만 출력 배포시
@@ -43,17 +43,24 @@ class Program
};
// 게임 서버 스레드 생성
Thread serverThread = new Thread(() =>
{
gameServer.Init();
gameServer.Run();
});
// Thread serverThread = new Thread(() =>
// {
// gameServer.Init();
// gameServer.Run();
// });
// 게임 서버 스레드 시작
serverThread.Start();
// serverThread.Start();
// Run()이 끝날 때까지 대기
serverThread.Join();
// serverThread.Join();
// 비동기 변경
await Task.Run(async () =>
{
gameServer.Init();
await gameServer.Run();
});
// Log 종료
Log.CloseAndFlush();

View File

@@ -61,7 +61,7 @@ public abstract class ServerBase : INetEventListener
isListening = true;
}
public virtual void Run()
public async Task Run()
{
netManager.Start(Port);
Log.Information("[Server] 시작 Port={Port}", Port);
@@ -69,7 +69,7 @@ public abstract class ServerBase : INetEventListener
while (isListening)
{
netManager.PollEvents();
Thread.Sleep(15);
await Task.Delay(1);
}
netManager.Stop();
Log.Information("[Server] 종료 Port={Port}", Port);
@@ -193,7 +193,8 @@ public abstract class ServerBase : INetEventListener
short code = reader.GetShort();
short bodyLength = reader.GetShort();
Log.Debug("[Echo] : addr={Addr}, str={Str}", peer.Address, reader.GetString());
SendTo(peer, payload);
// Echo메시지는 순서보장 안함 HOL Blocking 제거
SendTo(peer, payload, DeliveryMethod.ReliableUnordered);
}
// ─── Auth 처리 (내부) ────────────────────────────────────────────────