fix : playerID == hashkey 통일 / long => int로 변경

This commit is contained in:
qornwh1
2026-03-08 20:47:23 +09:00
parent 1b7f0003fb
commit 5165b9e6dc
12 changed files with 63 additions and 63 deletions

View File

@@ -12,7 +12,7 @@ public class DummyClients
private EventBasedNetListener listener; private EventBasedNetListener listener;
private NetDataWriter? writer; private NetDataWriter? writer;
public NetPeer? peer; public NetPeer? peer;
public long clientId; // 일단 이게 hashKey가 됨 => 0 ~ 1000번까지는 더미용응로 뺴둠 public int clientId; // 일단 이게 hashKey가 됨 => 0 ~ 1000번까지는 더미용응로 뺴둠
// info // info
private Vector3 position = new Vector3(); private Vector3 position = new Vector3();
@@ -50,7 +50,7 @@ public class DummyClients
get; get;
} }
public DummyClients(long clientId, string ip, int port, string key) public DummyClients(int clientId, string ip, int port, string key)
{ {
this.clientId = clientId; this.clientId = clientId;
listener = new EventBasedNetListener(); listener = new EventBasedNetListener();
@@ -139,7 +139,7 @@ public class DummyClients
UpdateDummy(); UpdateDummy();
TransformPlayerPacket transformPlayerPacket = new TransformPlayerPacket TransformPlayerPacket transformPlayerPacket = new TransformPlayerPacket
{ {
PlayerId = (int)clientId, PlayerId = clientId,
RotY = rotY, RotY = rotY,
Position = new Packet.Vector3 Position = new Packet.Vector3
{ {

View File

@@ -125,7 +125,7 @@ public class PlayerInfo
public class DummyAccTokenPacket public class DummyAccTokenPacket
{ {
[ProtoMember(1)] [ProtoMember(1)]
public long Token public int Token
{ {
get; get;
set; set;
@@ -533,7 +533,7 @@ public enum PartyUpdateType
public class UpdatePartyPacket public class UpdatePartyPacket
{ {
[ProtoMember(1)] [ProtoMember(1)]
public int PartyId public long PartyId
{ {
get; get;
set; set;

View File

@@ -18,7 +18,7 @@ public class StressTestClient
private EventBasedNetListener listener; private EventBasedNetListener listener;
private NetDataWriter? writer; private NetDataWriter? writer;
public NetPeer? peer; public NetPeer? peer;
public long clientId; public int clientId;
// 이동 // 이동
private Vector3 position = new Vector3(); private Vector3 position = new Vector3();
@@ -47,7 +47,7 @@ public class StressTestClient
public double AvgRttMs => RttCount > 0 ? TotalRttMs / RttCount : 0; public double AvgRttMs => RttCount > 0 ? TotalRttMs / RttCount : 0;
public bool IsConnected => peer != null; public bool IsConnected => peer != null;
public StressTestClient(long clientId, string ip, int port, string key) public StressTestClient(int clientId, string ip, int port, string key)
{ {
this.clientId = clientId; this.clientId = clientId;
listener = new EventBasedNetListener(); listener = new EventBasedNetListener();
@@ -150,7 +150,7 @@ public class StressTestClient
// 전송 // 전송
TransformPlayerPacket pkt = new TransformPlayerPacket TransformPlayerPacket pkt = new TransformPlayerPacket
{ {
PlayerId = (int)clientId, PlayerId = clientId,
RotY = rotY, RotY = rotY,
Position = new Packet.Vector3 { X = position.X, Y = 0, Z = position.Z } Position = new Packet.Vector3 { X = position.X, Y = 0, Z = position.Z }
}; };

View File

@@ -107,7 +107,7 @@ public class StressTestService
for (int i = 0; i < batch; i++) for (int i = 0; i < batch; i++)
{ {
long id = created + 1; // 1-based (더미 범위) int id = created + 1; // 1-based (더미 범위)
StressTestClient client = new StressTestClient(id, ip, port, key); StressTestClient client = new StressTestClient(id, ip, port, key);
lock (clientsLock) lock (clientsLock)
{ {

View File

@@ -9,10 +9,10 @@ public class Channel
private Robby robby = new Robby(); private Robby robby = new Robby();
// 채널 내 유저 상태 (hashKey → Player) // 채널 내 유저 상태 (hashKey → Player)
private Dictionary<long, Player> connectUsers = new Dictionary<long, Player>(); private Dictionary<int, Player> connectUsers = new Dictionary<int, Player>();
// 채널 내 유저 NetPeer (hashKey → NetPeer) — BroadcastToChannel 교차 조회 제거용 // 채널 내 유저 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 public int ChannelId
{ {
@@ -37,14 +37,14 @@ public class Channel
ChannelId = channelId; ChannelId = channelId;
} }
public void AddUser(long userId, Player player, NetPeer peer) public void AddUser(int userId, Player player, NetPeer peer)
{ {
connectUsers[userId] = player; connectUsers[userId] = player;
connectPeers[userId] = peer; connectPeers[userId] = peer;
UserCount++; UserCount++;
} }
public void RemoveUser(long userId) public void RemoveUser(int userId)
{ {
connectUsers.Remove(userId); connectUsers.Remove(userId);
connectPeers.Remove(userId); connectPeers.Remove(userId);
@@ -52,13 +52,13 @@ public class Channel
} }
// 재연결(WiFi→LTE 등) 시 동일 유저의 peer 교체 // 재연결(WiFi→LTE 등) 시 동일 유저의 peer 교체
public void UpdatePeer(long userId, NetPeer peer) public void UpdatePeer(int userId, NetPeer peer)
{ {
connectPeers[userId] = peer; connectPeers[userId] = peer;
} }
// 채널 내 모든 유저의 hashKey 반환 (채널 입장 시 기존 플레이어 목록 조회용) // 채널 내 모든 유저의 hashKey 반환 (채널 입장 시 기존 플레이어 목록 조회용)
public IEnumerable<long> GetConnectUsers() public IEnumerable<int> GetConnectUsers()
{ {
return connectUsers.Keys; return connectUsers.Keys;
} }
@@ -76,13 +76,13 @@ public class Channel
} }
// 특정 유저의 Player 반환 // 특정 유저의 Player 반환
public Player? GetPlayer(long userId) public Player? GetPlayer(int userId)
{ {
connectUsers.TryGetValue(userId, out Player? player); connectUsers.TryGetValue(userId, out Player? player);
return player; return player;
} }
public int HasUser(long userId) public int HasUser(int userId)
{ {
if (connectUsers.ContainsKey(userId)) if (connectUsers.ContainsKey(userId))
{ {

View File

@@ -1,4 +1,4 @@
using LiteNetLib; using LiteNetLib;
using MMOserver.Utils; using MMOserver.Utils;
namespace MMOserver.Game.Channel; namespace MMOserver.Game.Channel;
@@ -9,7 +9,7 @@ public class ChannelManager : Singleton<ChannelManager>
private List<Channel> channels = new List<Channel>(); private List<Channel> channels = new List<Channel>();
// 채널별 유저 관리 (유저 key, 채널 val) // 채널별 유저 관리 (유저 key, 채널 val)
private Dictionary<long, int> connectUsers = new Dictionary<long, int>(); private Dictionary<int, int> connectUsers = new Dictionary<int, int>();
public ChannelManager() public ChannelManager()
{ {
@@ -34,7 +34,7 @@ public class ChannelManager : Singleton<ChannelManager>
return channels; 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); connectUsers.Add(userId, channelId);
@@ -42,7 +42,7 @@ public class ChannelManager : Singleton<ChannelManager>
channels[channelId].AddUser(userId, player, peer); channels[channelId].AddUser(userId, player, peer);
} }
public bool RemoveUser(long userId) public bool RemoveUser(int userId)
{ {
// 채널에 없는 유저면 스킵 // 채널에 없는 유저면 스킵
if (!connectUsers.TryGetValue(userId, out int channelId)) if (!connectUsers.TryGetValue(userId, out int channelId))
@@ -61,7 +61,7 @@ public class ChannelManager : Singleton<ChannelManager>
return false; return false;
} }
public int HasUser(long userId) public int HasUser(int userId)
{ {
int channelId = -1; int channelId = -1;
if (connectUsers.ContainsKey(userId)) if (connectUsers.ContainsKey(userId))
@@ -77,7 +77,7 @@ public class ChannelManager : Singleton<ChannelManager>
return channelId; return channelId;
} }
public Dictionary<long, int> GetConnectUsers() public Dictionary<int, int> GetConnectUsers()
{ {
return connectUsers; return connectUsers;
} }

View File

@@ -13,12 +13,12 @@ namespace MMOserver.Game;
public class GameServer : ServerBase public class GameServer : ServerBase
{ {
private readonly Dictionary<ushort, Action<NetPeer, long, byte[]>> packetHandlers; private readonly Dictionary<ushort, Action<NetPeer, int, byte[]>> packetHandlers;
private UuidGenerator userUuidGenerator; private UuidGenerator userUuidGenerator;
public GameServer(int port, string connectionString) : base(port, connectionString) public GameServer(int port, string connectionString) : base(port, connectionString)
{ {
packetHandlers = new Dictionary<ushort, Action<NetPeer, long, byte[]>> packetHandlers = new Dictionary<ushort, Action<NetPeer, int, byte[]>>
{ {
[(ushort)PacketCode.INTO_CHANNEL] = OnIntoChannel, [(ushort)PacketCode.INTO_CHANNEL] = OnIntoChannel,
[(ushort)PacketCode.EXIT_CHANNEL] = OnExitChannel, [(ushort)PacketCode.EXIT_CHANNEL] = OnExitChannel,
@@ -51,7 +51,7 @@ public class GameServer : ServerBase
protected override void HandleAuthDummy(NetPeer peer, byte[] payload) protected override void HandleAuthDummy(NetPeer peer, byte[] payload)
{ {
DummyAccTokenPacket accTokenPacket = Serializer.Deserialize<DummyAccTokenPacket>(new ReadOnlyMemory<byte>(payload)); DummyAccTokenPacket accTokenPacket = Serializer.Deserialize<DummyAccTokenPacket>(new ReadOnlyMemory<byte>(payload));
long hashKey = accTokenPacket.Token; int hashKey = accTokenPacket.Token;
if (sessions.TryGetValue(hashKey, out NetPeer? existing)) if (sessions.TryGetValue(hashKey, out NetPeer? existing))
{ {
@@ -73,8 +73,8 @@ public class GameServer : ServerBase
Player newPlayer = new Player Player newPlayer = new Player
{ {
HashKey = hashKey, HashKey = hashKey,
PlayerId = (int)(hashKey & 0x7FFFFFFF), PlayerId = hashKey,
Nickname = (hashKey & 0x7FFFFFFF).ToString() Nickname = hashKey.ToString()
}; };
cm.AddUser(1, hashKey, newPlayer, peer); cm.AddUser(1, hashKey, newPlayer, peer);
@@ -94,7 +94,7 @@ public class GameServer : ServerBase
{ {
AccTokenPacket accTokenPacket = Serializer.Deserialize<AccTokenPacket>(new ReadOnlyMemory<byte>(payload)); AccTokenPacket accTokenPacket = Serializer.Deserialize<AccTokenPacket>(new ReadOnlyMemory<byte>(payload));
string token = accTokenPacket.Token; string token = accTokenPacket.Token;
tokenHash.TryGetValue(token, out long hashKey); tokenHash.TryGetValue(token, out int hashKey);
if (hashKey <= 1000) if (hashKey <= 1000)
{ {
hashKey = userUuidGenerator.Create(); hashKey = userUuidGenerator.Create();
@@ -133,7 +133,7 @@ public class GameServer : ServerBase
OnSessionConnected(peer, hashKey); OnSessionConnected(peer, hashKey);
} }
protected override void OnSessionConnected(NetPeer peer, long hashKey) protected override void OnSessionConnected(NetPeer peer, int hashKey)
{ {
Log.Information("[GameServer] 세션 연결 HashKey={Key} PeerId={Id}", hashKey, peer.Id); Log.Information("[GameServer] 세션 연결 HashKey={Key} PeerId={Id}", hashKey, peer.Id);
@@ -154,7 +154,7 @@ public class GameServer : ServerBase
} }
} }
protected override void OnSessionDisconnected(NetPeer peer, long hashKey, DisconnectInfo info) protected override void OnSessionDisconnected(NetPeer peer, int hashKey, DisconnectInfo info)
{ {
ChannelManager cm = ChannelManager.Instance; ChannelManager cm = ChannelManager.Instance;
@@ -176,9 +176,9 @@ public class GameServer : ServerBase
userUuidGenerator.Release(hashKey); userUuidGenerator.Release(hashKey);
} }
protected override void HandlePacket(NetPeer peer, long hashKey, ushort type, byte[] payload) protected override void HandlePacket(NetPeer peer, int hashKey, ushort type, byte[] payload)
{ {
if (packetHandlers.TryGetValue(type, out Action<NetPeer, long, byte[]>? handler)) if (packetHandlers.TryGetValue(type, out Action<NetPeer, int, byte[]>? handler))
{ {
handler(peer, hashKey, payload); handler(peer, hashKey, payload);
} }
@@ -192,7 +192,7 @@ public class GameServer : ServerBase
// 보내는 패킷 // 보내는 패킷
// ============================================================ // ============================================================
private void SendLoadChannelPacket(NetPeer peer, long hashKey) private void SendLoadChannelPacket(NetPeer peer, int hashKey)
{ {
LoadChannelPacket loadChannelPacket = new LoadChannelPacket(); LoadChannelPacket loadChannelPacket = new LoadChannelPacket();
foreach (Channel.Channel channel in ChannelManager.Instance.GetChannels()) foreach (Channel.Channel channel in ChannelManager.Instance.GetChannels())
@@ -209,7 +209,7 @@ public class GameServer : ServerBase
} }
// 나간 유저를 같은 채널 유저들에게 알림 (UPDATE_CHANNEL_USER IsAdd=false) // 나간 유저를 같은 채널 유저들에게 알림 (UPDATE_CHANNEL_USER IsAdd=false)
private void SendExitChannelPacket(NetPeer peer, long hashKey, int channelId, Player player) private void SendExitChannelPacket(NetPeer peer, int hashKey, int channelId, Player player)
{ {
UpdateChannelUserPacket packet = new UpdateChannelUserPacket UpdateChannelUserPacket packet = new UpdateChannelUserPacket
{ {
@@ -224,7 +224,7 @@ public class GameServer : ServerBase
// 채널 입장 시 패킷 전송 // 채널 입장 시 패킷 전송
// - 새 유저에게 : 기존 채널 유저 목록 (INTO_CHANNEL) // - 새 유저에게 : 기존 채널 유저 목록 (INTO_CHANNEL)
// - 기존 유저들에게 : 새 유저 입장 알림 (UPDATE_CHANNEL_USER IsAdd=true) // - 기존 유저들에게 : 새 유저 입장 알림 (UPDATE_CHANNEL_USER IsAdd=true)
private void SendIntoChannelPacket(NetPeer peer, long hashKey) private void SendIntoChannelPacket(NetPeer peer, int hashKey)
{ {
ChannelManager cm = ChannelManager.Instance; ChannelManager cm = ChannelManager.Instance;
int channelId = cm.HasUser(hashKey); int channelId = cm.HasUser(hashKey);
@@ -238,7 +238,7 @@ public class GameServer : ServerBase
// 1. 새 유저에게: 자신을 제외한 기존 채널 유저 목록 전송 // 1. 새 유저에게: 자신을 제외한 기존 채널 유저 목록 전송
IntoChannelPacket response = new IntoChannelPacket { ChannelId = channelId }; IntoChannelPacket response = new IntoChannelPacket { ChannelId = channelId };
foreach (long userId in channel.GetConnectUsers()) foreach (int userId in channel.GetConnectUsers())
{ {
if (userId == hashKey) if (userId == hashKey)
{ {
@@ -270,7 +270,7 @@ public class GameServer : ServerBase
// 채널 입장 시 패킷 전송 // 채널 입장 시 패킷 전송
// - 자신 유저에게 : 내 정보 (LOAD_GAME) // - 자신 유저에게 : 내 정보 (LOAD_GAME)
private void SendLoadGame(NetPeer peer, long hashKey) private void SendLoadGame(NetPeer peer, int hashKey)
{ {
ChannelManager cm = ChannelManager.Instance; ChannelManager cm = ChannelManager.Instance;
int channelId = cm.HasUser(hashKey); int channelId = cm.HasUser(hashKey);
@@ -340,7 +340,7 @@ public class GameServer : ServerBase
// 패킷 핸들러 // 패킷 핸들러
// ============================================================ // ============================================================
private void OnIntoChannel(NetPeer peer, long hashKey, byte[] payload) private void OnIntoChannel(NetPeer peer, int hashKey, byte[] payload)
{ {
IntoChannelPacket packet = Serializer.Deserialize<IntoChannelPacket>(new ReadOnlyMemory<byte>(payload)); IntoChannelPacket packet = Serializer.Deserialize<IntoChannelPacket>(new ReadOnlyMemory<byte>(payload));
@@ -361,8 +361,8 @@ public class GameServer : ServerBase
Player newPlayer = new Player Player newPlayer = new Player
{ {
HashKey = hashKey, HashKey = hashKey,
PlayerId = (int)(hashKey & 0x7FFFFFFF), PlayerId = hashKey,
Nickname = (hashKey & 0x7FFFFFFF).ToString() Nickname = hashKey.ToString()
}; };
cm.AddUser(packet.ChannelId, hashKey, newPlayer, peer); cm.AddUser(packet.ChannelId, hashKey, newPlayer, peer);
@@ -375,7 +375,7 @@ public class GameServer : ServerBase
SendLoadGame(peer, hashKey); SendLoadGame(peer, hashKey);
} }
private void OnExitChannel(NetPeer peer, long hashKey, byte[] payload) private void OnExitChannel(NetPeer peer, int hashKey, byte[] payload)
{ {
ExitChannelPacket packet = Serializer.Deserialize<ExitChannelPacket>(new ReadOnlyMemory<byte>(payload)); ExitChannelPacket packet = Serializer.Deserialize<ExitChannelPacket>(new ReadOnlyMemory<byte>(payload));
@@ -395,7 +395,7 @@ public class GameServer : ServerBase
} }
} }
private void OnTransformPlayer(NetPeer peer, long hashKey, byte[] payload) private void OnTransformPlayer(NetPeer peer, int hashKey, byte[] payload)
{ {
TransformPlayerPacket packet = Serializer.Deserialize<TransformPlayerPacket>(new ReadOnlyMemory<byte>(payload)); TransformPlayerPacket packet = Serializer.Deserialize<TransformPlayerPacket>(new ReadOnlyMemory<byte>(payload));
@@ -421,7 +421,7 @@ public class GameServer : ServerBase
BroadcastToChannel(channelId, data, peer, DeliveryMethod.Unreliable); BroadcastToChannel(channelId, data, peer, DeliveryMethod.Unreliable);
} }
private void OnActionPlayer(NetPeer peer, long hashKey, byte[] payload) private void OnActionPlayer(NetPeer peer, int hashKey, byte[] payload)
{ {
ActionPlayerPacket packet = Serializer.Deserialize<ActionPlayerPacket>(new ReadOnlyMemory<byte>(payload)); ActionPlayerPacket packet = Serializer.Deserialize<ActionPlayerPacket>(new ReadOnlyMemory<byte>(payload));
@@ -437,7 +437,7 @@ public class GameServer : ServerBase
BroadcastToChannel(channelId, data, peer); BroadcastToChannel(channelId, data, peer);
} }
private void OnStatePlayer(NetPeer peer, long hashKey, byte[] payload) private void OnStatePlayer(NetPeer peer, int hashKey, byte[] payload)
{ {
StatePlayerPacket packet = Serializer.Deserialize<StatePlayerPacket>(new ReadOnlyMemory<byte>(payload)); StatePlayerPacket packet = Serializer.Deserialize<StatePlayerPacket>(new ReadOnlyMemory<byte>(payload));

View File

@@ -2,7 +2,7 @@ namespace MMOserver.Game;
public class Player public class Player
{ {
public long HashKey public int HashKey
{ {
get; get;
set; set;

View File

@@ -125,7 +125,7 @@ public class PlayerInfo
public class DummyAccTokenPacket public class DummyAccTokenPacket
{ {
[ProtoMember(1)] [ProtoMember(1)]
public long Token public int Token
{ {
get; get;
set; set;
@@ -533,7 +533,7 @@ public enum PartyUpdateType
public class UpdatePartyPacket public class UpdatePartyPacket
{ {
[ProtoMember(1)] [ProtoMember(1)]
public int PartyId public long PartyId
{ {
get; get;
set; set;

View File

@@ -3,20 +3,20 @@ namespace MMOserver.Utils;
public class UuidGenerator public class UuidGenerator
{ {
// 0 ~ 1000 은 더미 클라이언트 예약 범위 // 0 ~ 1000 은 더미 클라이언트 예약 범위
private const long DUMMY_RANGE_MAX = 1000; private const int DUMMY_RANGE_MAX = 1000;
private readonly object idLock = new(); private readonly object idLock = new();
private readonly HashSet<long> usedIds = new(); private readonly HashSet<int> usedIds = new();
// 고유 랜덤 long ID 발급 (1001번 이상, 충돌 시 재생성) // 고유 랜덤 int ID 발급 (1001번 이상, 충돌 시 재생성)
public long Create() public int Create()
{ {
lock (idLock) lock (idLock)
{ {
long id; int id;
do do
{ {
id = Random.Shared.NextInt64(DUMMY_RANGE_MAX + 1, long.MaxValue); id = Random.Shared.Next(DUMMY_RANGE_MAX + 1, int.MaxValue);
} while (usedIds.Contains(id)); } while (usedIds.Contains(id));
usedIds.Add(id); usedIds.Add(id);
@@ -25,7 +25,7 @@ public class UuidGenerator
} }
// 로그아웃 / 세션 만료 시 ID 반납 // 로그아웃 / 세션 만료 시 ID 반납
public bool Release(long id) public bool Release(int id)
{ {
lock (idLock) lock (idLock)
{ {

View File

@@ -15,7 +15,7 @@ namespace ServerLib.Service;
/// ///
/// 흐름: /// 흐름:
/// OnPeerConnected → 대기 목록 등록 /// OnPeerConnected → 대기 목록 등록
/// OnNetworkReceive → Auth 패킷(type=1)이면 HashKey(8byte long) 읽어 인증 /// OnNetworkReceive → Auth 패킷(type=1)이면 HashKey(4byte int) 읽어 인증
/// → 이미 같은 HashKey 세션 있으면 이전 피어 끊고 재연결 (WiFi→LTE) /// → 이미 같은 HashKey 세션 있으면 이전 피어 끊고 재연결 (WiFi→LTE)
/// → 그 외 패킷은 HandlePacket() 으로 전달 /// → 그 외 패킷은 HandlePacket() 으로 전달
/// OnPeerDisconnected → 세션/대기 목록에서 제거 /// OnPeerDisconnected → 세션/대기 목록에서 제거
@@ -34,10 +34,10 @@ public abstract class ServerBase : INetEventListener
// 인증된 세션 (hashKey → NetPeer) 재연결 조회용 // 인증된 세션 (hashKey → NetPeer) 재연결 조회용
// peer → hashKey 역방향은 peer.Tag as Session 으로 대체 // peer → hashKey 역방향은 peer.Tag as Session 으로 대체
protected readonly Dictionary<long, NetPeer> sessions = new(); protected readonly Dictionary<int, NetPeer> sessions = new();
// Token / HashKey 관리 // Token / HashKey 관리
protected readonly Dictionary<string, long> tokenHash = new(); protected readonly Dictionary<string, int> tokenHash = new();
// 재사용 NetDataWriter (단일 스레드 폴링이므로 안전) // 재사용 NetDataWriter (단일 스레드 폴링이므로 안전)
private readonly NetDataWriter cachedWriter = new(); private readonly NetDataWriter cachedWriter = new();
@@ -271,11 +271,11 @@ public abstract class ServerBase : INetEventListener
// ─── 서브클래스 구현 ───────────────────────────────────────────────── // ─── 서브클래스 구현 ─────────────────────────────────────────────────
// 인증(Auth) 완료 후 호출 // 인증(Auth) 완료 후 호출
protected abstract void OnSessionConnected(NetPeer peer, long hashKey); protected abstract void OnSessionConnected(NetPeer peer, int hashKey);
// 세션 정상 해제 시 호출 (재연결 교체 시에는 호출되지 않음) // 세션 정상 해제 시 호출 (재연결 교체 시에는 호출되지 않음)
protected abstract void OnSessionDisconnected(NetPeer peer, long hashKey, DisconnectInfo info); protected abstract void OnSessionDisconnected(NetPeer peer, int hashKey, DisconnectInfo info);
// 인증된 피어의 게임 패킷 수신 / payload는 헤더 제거된 raw bytes → 실행 프로젝트에서 protobuf 역직렬화 // 인증된 피어의 게임 패킷 수신 / payload는 헤더 제거된 raw bytes → 실행 프로젝트에서 protobuf 역직렬화
protected abstract void HandlePacket(NetPeer peer, long hashKey, ushort type, byte[] payload); protected abstract void HandlePacket(NetPeer peer, int hashKey, ushort type, byte[] payload);
} }

View File

@@ -10,7 +10,7 @@ public class Session
set; set;
} }
public long HashKey public int HashKey
{ {
get; get;
init; init;
@@ -63,7 +63,7 @@ public class Session
RateLimitViolations = 0; RateLimitViolations = 0;
} }
public Session(long hashKey, NetPeer peer, int maxPacketsPerSecond = 60) public Session(int hashKey, NetPeer peer, int maxPacketsPerSecond = 60)
{ {
HashKey = hashKey; HashKey = hashKey;
Peer = peer; Peer = peer;