feat : 채널 매니저(각 채널, 유저 관리) 구현 / 유저 정보 구현 / 패킷 이동 채널 접속 구현

This commit is contained in:
qornwh1
2026-03-03 17:43:07 +09:00
parent a9e1d2acaf
commit f75d71c1ee
9 changed files with 748 additions and 234 deletions

View File

@@ -0,0 +1,82 @@
using MMOserver.Game.Channel.Maps;
namespace MMOserver.Game.Channel;
public class Channel
{
// 로비
private Robby robby = new Robby();
// 채널 내 유저 상태 (hashKey → Player)
private Dictionary<long, Player> connectUsers = new Dictionary<long, Player>();
public int ChannelId
{
get;
private set;
}
public int UserCount
{
get;
private set;
}
public int UserCountMax
{
get;
private set;
} = 100;
public Channel(int channelId)
{
ChannelId = channelId;
}
public void AddUser(long userId, Player player)
{
connectUsers[userId] = player;
UserCount++;
}
public void RemoveUser(long userId)
{
connectUsers.Remove(userId);
UserCount--;
}
// 채널 내 모든 유저의 hashKey 반환
public IEnumerable<long> GetConnectUsers()
{
return connectUsers.Keys;
}
// 채널 내 모든 Player 반환
public IEnumerable<Player> GetPlayers()
{
return connectUsers.Values;
}
// 특정 유저의 Player 반환
public Player? GetPlayer(long userId)
{
connectUsers.TryGetValue(userId, out Player? player);
return player;
}
public int HasUser(long userId)
{
if (connectUsers.ContainsKey(userId))
{
return ChannelId;
}
return -1;
}
// 로비 가져옴
public Robby GetRobby()
{
return robby;
}
}