feat : 서버 로직 성능개선 / 결과 정리

This commit is contained in:
qornwh1
2026-03-06 10:16:36 +09:00
parent 85c3276207
commit 2a7d4aeb09
5 changed files with 159 additions and 35 deletions

View File

@@ -68,7 +68,7 @@ public class GameServer : ServerBase
{
// 더미 클라다.
ChannelManager cm = ChannelManager.Instance;
cm.AddUser(1, hashKey, new Player());
cm.AddUser(1, hashKey, new Player(), peer);
}
else
{
@@ -134,7 +134,8 @@ public class GameServer : ServerBase
if (channelId >= 0)
{
// 재연결: 채널 유저 목록 전송 (채널 선택 스킵, 바로 마을로)
// 재연결: Channel 내 peer 참조 갱신 후 채널 유저 목록 전송
cm.GetChannel(channelId).UpdatePeer(hashKey, peer);
SendIntoChannelPacket(peer, hashKey);
}
else
@@ -263,16 +264,12 @@ public class GameServer : ServerBase
// ============================================================
// 특정 채널의 모든 유저에게 전송 (exclude 지정 시 해당 피어 제외)
// Channel이 NetPeer를 직접 보유하므로 sessions 교차 조회 없음
private void BroadcastToChannel(int channelId, byte[] data, NetPeer? exclude = null, DeliveryMethod method = DeliveryMethod.ReliableOrdered)
{
Channel.Channel channel = ChannelManager.Instance.GetChannel(channelId);
foreach (long userId in channel.GetConnectUsers())
foreach (NetPeer targetPeer in channel.GetConnectPeers())
{
if (!sessions.TryGetValue(userId, out NetPeer? targetPeer))
{
continue;
}
if (exclude != null && targetPeer.Id == exclude.Id)
{
continue;
@@ -330,7 +327,7 @@ public class GameServer : ServerBase
PlayerId = (int)(hashKey & 0x7FFFFFFF),
};
cm.AddUser(packet.ChannelId, hashKey, newPlayer);
cm.AddUser(packet.ChannelId, hashKey, newPlayer, peer);
Log.Debug("[GameServer] INTO_CHANNEL HashKey={Key} ChannelId={ChannelId}", hashKey, packet.ChannelId);
// 접속된 모든 유저 정보 전달