feat : 채널 접속시 내 정보도 전달

This commit is contained in:
qornwh1
2026-03-06 16:10:35 +09:00
parent 1285284aa1
commit d36de75534

View File

@@ -265,6 +265,34 @@ public class GameServer : ServerBase
} }
} }
// 채널 입장 시 패킷 전송
// - 자신 유저에게 : 내 정보 (LOAD_GAME)
private void SendLoadGame(NetPeer peer, long hashKey)
{
ChannelManager cm = ChannelManager.Instance;
int channelId = cm.HasUser(hashKey);
Player? player = channelId >= 0 ? cm.GetChannel(channelId).GetPlayer(hashKey) : null;
if (player == null)
{
Log.Warning("[GameServer] LOAD_GAME 플레이어 없음 HashKey={Key}", hashKey);
byte[] denied = PacketSerializer.Serialize<LoadGamePacket>((ushort)PacketCode.LOAD_GAME, new LoadGamePacket { IsAccepted = false });
SendTo(peer, denied);
return;
}
LoadGamePacket packet = new LoadGamePacket
{
IsAccepted = true,
Player = ToPlayerInfo(player),
MaplId = channelId,
};
byte[] data = PacketSerializer.Serialize<LoadGamePacket>((ushort)PacketCode.LOAD_GAME, packet);
SendTo(peer, data);
Log.Debug("[GameServer] LOAD_GAME HashKey={Key} PlayerId={PlayerId} ChannelId={ChannelId}", hashKey, player.PlayerId, channelId);
}
// ============================================================ // ============================================================
// 채널 브로드캐스트 헬퍼 // 채널 브로드캐스트 헬퍼
// ============================================================ // ============================================================
@@ -338,6 +366,9 @@ public class GameServer : ServerBase
// 접속된 모든 유저 정보 전달 // 접속된 모든 유저 정보 전달
SendIntoChannelPacket(peer, hashKey); SendIntoChannelPacket(peer, hashKey);
// 내 정보 전달
SendLoadGame(peer, hashKey);
} }
private void OnExitChannel(NetPeer peer, long hashKey, byte[] payload) private void OnExitChannel(NetPeer peer, long hashKey, byte[] payload)