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

@@ -15,7 +15,7 @@ namespace ServerLib.Service;
///
/// 흐름:
/// OnPeerConnected → 대기 목록 등록
/// OnNetworkReceive → Auth 패킷(type=1)이면 HashKey(8byte long) 읽어 인증
/// OnNetworkReceive → Auth 패킷(type=1)이면 HashKey(4byte int) 읽어 인증
/// → 이미 같은 HashKey 세션 있으면 이전 피어 끊고 재연결 (WiFi→LTE)
/// → 그 외 패킷은 HandlePacket() 으로 전달
/// OnPeerDisconnected → 세션/대기 목록에서 제거
@@ -34,10 +34,10 @@ public abstract class ServerBase : INetEventListener
// 인증된 세션 (hashKey → NetPeer) 재연결 조회용
// peer → hashKey 역방향은 peer.Tag as Session 으로 대체
protected readonly Dictionary<long, NetPeer> sessions = new();
protected readonly Dictionary<int, NetPeer> sessions = new();
// Token / HashKey 관리
protected readonly Dictionary<string, long> tokenHash = new();
protected readonly Dictionary<string, int> tokenHash = new();
// 재사용 NetDataWriter (단일 스레드 폴링이므로 안전)
private readonly NetDataWriter cachedWriter = new();
@@ -271,11 +271,11 @@ public abstract class ServerBase : INetEventListener
// ─── 서브클래스 구현 ─────────────────────────────────────────────────
// 인증(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 역직렬화
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;
}
public long HashKey
public int HashKey
{
get;
init;
@@ -63,7 +63,7 @@ public class Session
RateLimitViolations = 0;
}
public Session(long hashKey, NetPeer peer, int maxPacketsPerSecond = 60)
public Session(int hashKey, NetPeer peer, int maxPacketsPerSecond = 60)
{
HashKey = hashKey;
Peer = peer;