fix : playerID == hashkey 통일 / long => int로 변경
This commit is contained in:
@@ -9,10 +9,10 @@ public class Channel
|
||||
private Robby robby = new Robby();
|
||||
|
||||
// 채널 내 유저 상태 (hashKey → Player)
|
||||
private Dictionary<long, Player> connectUsers = new Dictionary<long, Player>();
|
||||
private Dictionary<int, Player> connectUsers = new Dictionary<int, Player>();
|
||||
|
||||
// 채널 내 유저 NetPeer (hashKey → NetPeer) — BroadcastToChannel 교차 조회 제거용
|
||||
private Dictionary<long, NetPeer> connectPeers = new Dictionary<long, NetPeer>();
|
||||
private Dictionary<int, NetPeer> connectPeers = new Dictionary<int, NetPeer>();
|
||||
|
||||
public int ChannelId
|
||||
{
|
||||
@@ -37,14 +37,14 @@ public class Channel
|
||||
ChannelId = channelId;
|
||||
}
|
||||
|
||||
public void AddUser(long userId, Player player, NetPeer peer)
|
||||
public void AddUser(int userId, Player player, NetPeer peer)
|
||||
{
|
||||
connectUsers[userId] = player;
|
||||
connectPeers[userId] = peer;
|
||||
UserCount++;
|
||||
}
|
||||
|
||||
public void RemoveUser(long userId)
|
||||
public void RemoveUser(int userId)
|
||||
{
|
||||
connectUsers.Remove(userId);
|
||||
connectPeers.Remove(userId);
|
||||
@@ -52,13 +52,13 @@ public class Channel
|
||||
}
|
||||
|
||||
// 재연결(WiFi→LTE 등) 시 동일 유저의 peer 교체
|
||||
public void UpdatePeer(long userId, NetPeer peer)
|
||||
public void UpdatePeer(int userId, NetPeer peer)
|
||||
{
|
||||
connectPeers[userId] = peer;
|
||||
}
|
||||
|
||||
// 채널 내 모든 유저의 hashKey 반환 (채널 입장 시 기존 플레이어 목록 조회용)
|
||||
public IEnumerable<long> GetConnectUsers()
|
||||
public IEnumerable<int> GetConnectUsers()
|
||||
{
|
||||
return connectUsers.Keys;
|
||||
}
|
||||
@@ -76,13 +76,13 @@ public class Channel
|
||||
}
|
||||
|
||||
// 특정 유저의 Player 반환
|
||||
public Player? GetPlayer(long userId)
|
||||
public Player? GetPlayer(int userId)
|
||||
{
|
||||
connectUsers.TryGetValue(userId, out Player? player);
|
||||
return player;
|
||||
}
|
||||
|
||||
public int HasUser(long userId)
|
||||
public int HasUser(int userId)
|
||||
{
|
||||
if (connectUsers.ContainsKey(userId))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using LiteNetLib;
|
||||
using LiteNetLib;
|
||||
using MMOserver.Utils;
|
||||
|
||||
namespace MMOserver.Game.Channel;
|
||||
@@ -9,7 +9,7 @@ public class ChannelManager : Singleton<ChannelManager>
|
||||
private List<Channel> channels = new List<Channel>();
|
||||
|
||||
// 채널별 유저 관리 (유저 key, 채널 val)
|
||||
private Dictionary<long, int> connectUsers = new Dictionary<long, int>();
|
||||
private Dictionary<int, int> connectUsers = new Dictionary<int, int>();
|
||||
|
||||
public ChannelManager()
|
||||
{
|
||||
@@ -34,7 +34,7 @@ public class ChannelManager : Singleton<ChannelManager>
|
||||
return channels;
|
||||
}
|
||||
|
||||
public void AddUser(int channelId, long userId, Player player, NetPeer peer)
|
||||
public void AddUser(int channelId, int userId, Player player, NetPeer peer)
|
||||
{
|
||||
// 유저 추가
|
||||
connectUsers.Add(userId, channelId);
|
||||
@@ -42,7 +42,7 @@ public class ChannelManager : Singleton<ChannelManager>
|
||||
channels[channelId].AddUser(userId, player, peer);
|
||||
}
|
||||
|
||||
public bool RemoveUser(long userId)
|
||||
public bool RemoveUser(int userId)
|
||||
{
|
||||
// 채널에 없는 유저면 스킵
|
||||
if (!connectUsers.TryGetValue(userId, out int channelId))
|
||||
@@ -61,7 +61,7 @@ public class ChannelManager : Singleton<ChannelManager>
|
||||
return false;
|
||||
}
|
||||
|
||||
public int HasUser(long userId)
|
||||
public int HasUser(int userId)
|
||||
{
|
||||
int channelId = -1;
|
||||
if (connectUsers.ContainsKey(userId))
|
||||
@@ -77,7 +77,7 @@ public class ChannelManager : Singleton<ChannelManager>
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public Dictionary<long, int> GetConnectUsers()
|
||||
public Dictionary<int, int> GetConnectUsers()
|
||||
{
|
||||
return connectUsers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user