feat : 보스 전용채널 제거, 채널 5개로 변경, config.json 정리

This commit is contained in:
qornwh1
2026-03-17 10:33:08 +09:00
parent f8fa34edbc
commit fb76f49ec0
5 changed files with 25 additions and 17 deletions

View File

@@ -73,7 +73,7 @@ public class RestApi : Singleton<RestApi>
// 성공 시 BossRaidResult 반환, 실패/거절 시 null 반환
public async Task<BossRaidResult?> BossRaidAccesssAsync(List<string> userNames, int bossId)
{
string url = AppConfig.RestApi.BaseUrl + "/api/internal/bossraid/entry";
string url = AppConfig.RestApi.BaseUrl + AppConfig.RestApi.BossRaidAccess;
for (int attempt = 1; attempt <= MAX_RETRY; attempt++)
{

View File

@@ -30,9 +30,15 @@ public sealed class ServerConfig
get;
}
public int ChannelCount
{
get;
}
public ServerConfig(IConfigurationSection section)
{
Port = int.Parse(section["Port"] ?? throw new InvalidOperationException("Server:Port is required in config.json"));
ChannelCount = int.Parse(section["ChannelCount"] ?? "1");
}
}
@@ -48,6 +54,11 @@ public sealed class RestApiConfig
get;
}
public string BossRaidAccess
{
get;
}
public string ApiKey
{
get;
@@ -57,6 +68,7 @@ public sealed class RestApiConfig
{
BaseUrl = section["BaseUrl"] ?? throw new InvalidOperationException("RestApi:BaseUrl is required in config.json");
VerifyToken = section["VerifyToken"] ?? throw new InvalidOperationException("RestApi:BaseUrl is required in config.json");
BossRaidAccess = section["BossRaidAccess"] ?? throw new InvalidOperationException("RestApi:BaseUrl is required in config.json");
ApiKey = section["ApiKey"] ?? throw new InvalidOperationException("RestApi:ApiKey is required in config.json");
}
}

View File

@@ -1,4 +1,5 @@
using LiteNetLib;
using MMOserver.Config;
using MMOserver.Utils;
namespace MMOserver.Game.Channel;
@@ -8,16 +9,12 @@ public class ChannelManager : Singleton<ChannelManager>
// 채널 관리
private Dictionary<int, Channel> channels = new Dictionary<int, Channel>();
// 보스 레이드 채널
private readonly int bossChannelStart = 10000;
private readonly int bossChannelSize = 10;
// 채널별 유저 관리 (유저 key, 채널 val)
private Dictionary<int, int> connectUsers = new Dictionary<int, int>();
public ChannelManager()
{
Initializer();
Initializer(AppConfig.Server.ChannelCount);
}
public void Initializer(int channelSize = 1)
@@ -26,13 +23,6 @@ public class ChannelManager : Singleton<ChannelManager>
{
channels.Add(i, new Channel(i));
}
// 보스 채널 생성
for (int i = 1; i <= bossChannelSize; i++)
{
int bossChannel = i + bossChannelStart;
channels.Add(bossChannel, new Channel(bossChannel));
}
}
public Channel GetChannel(int channelId)

View File

@@ -103,7 +103,7 @@ public class GameServer : ServerBase
{
AccTokenPacket accTokenPacket = Serializer.Deserialize<AccTokenPacket>(new ReadOnlyMemory<byte>(payload));
string token = accTokenPacket.Token;
string username = "";
string? username = "";
tokenHash.TryGetValue(token, out int hashKey);
if (hashKey <= 1000)
{
@@ -122,7 +122,7 @@ public class GameServer : ServerBase
{
// 신규 연결: 웹서버에 JWT 검증 요청
username = await RestApi.Instance.VerifyTokenAsync(token);
if (username == null)
if (username == null || username.Trim().Length <= 0)
{
Log.Warning("[Server] 토큰 검증 실패 - 연결 거부 PeerId={Id}", peer.Id);
userUuidGenerator.Release(hashKey);
@@ -1073,7 +1073,11 @@ public class GameServer : ServerBase
List<string> userNames = new List<string>();
foreach (int memberId in party.PartyMemberIds)
{
userNames.Add(channel.GetPlayer(memberId).Nickname);
Player? memberPlayer = channel.GetPlayer(memberId);
if (memberPlayer != null)
{
userNames.Add(memberPlayer.Nickname);
}
}
BossRaidResult? result = await RestApi.Instance.BossRaidAccesssAsync(userNames, 1);

View File

@@ -1,10 +1,12 @@
{
"Server": {
"Port": 9500
"Port": 9500,
"ChannelCount": 5
},
"RestApi": {
"BaseUrl": "https://a301.api.tolelom.xyz",
"VerifyToken": "/api/internal/auth/verify",
"BossRaidAccess": "/api/internal/bossraid/entry",
"ApiKey": "017f15b28143fc67d2e5bed283c37d2da858b9f294990a5334238e055e3f5425"
},
"Database": {