feat : UuidGenerator 여러곳에서 사용하도록 싱글톤 제거
This commit is contained in:
@@ -14,6 +14,7 @@ namespace MMOserver.Game;
|
||||
public class GameServer : ServerBase
|
||||
{
|
||||
private readonly Dictionary<ushort, Action<NetPeer, long, byte[]>> packetHandlers;
|
||||
private UuidGenerator userUuidGenerator;
|
||||
|
||||
public GameServer(int port, string connectionString) : base(port, connectionString)
|
||||
{
|
||||
@@ -25,6 +26,7 @@ public class GameServer : ServerBase
|
||||
[(ushort)PacketCode.ACTION_PLAYER] = OnActionPlayer,
|
||||
[(ushort)PacketCode.STATE_PLAYER] = OnStatePlayer,
|
||||
};
|
||||
userUuidGenerator = new UuidGenerator();
|
||||
}
|
||||
|
||||
protected override void HandleEcho(NetPeer peer, byte[] payload)
|
||||
@@ -95,7 +97,7 @@ public class GameServer : ServerBase
|
||||
tokenHash.TryGetValue(token, out long hashKey);
|
||||
if (hashKey <= 1000)
|
||||
{
|
||||
hashKey = UuidGeneratorManager.Instance.Create();
|
||||
hashKey = userUuidGenerator.Create();
|
||||
}
|
||||
|
||||
if (sessions.TryGetValue(hashKey, out NetPeer? existing))
|
||||
@@ -113,7 +115,7 @@ public class GameServer : ServerBase
|
||||
if (username == null)
|
||||
{
|
||||
Log.Warning("[Server] 토큰 검증 실패 - 연결 거부 PeerId={Id}", peer.Id);
|
||||
UuidGeneratorManager.Instance.Release(hashKey);
|
||||
userUuidGenerator.Release(hashKey);
|
||||
peer.Disconnect();
|
||||
return;
|
||||
}
|
||||
@@ -171,7 +173,7 @@ public class GameServer : ServerBase
|
||||
}
|
||||
}
|
||||
|
||||
UuidGeneratorManager.Instance.Release(hashKey);
|
||||
userUuidGenerator.Release(hashKey);
|
||||
}
|
||||
|
||||
protected override void HandlePacket(NetPeer peer, long hashKey, ushort type, byte[] payload)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace MMOserver.Utils;
|
||||
|
||||
public class UuidGeneratorManager : Singleton<UuidGeneratorManager>
|
||||
public class UuidGenerator
|
||||
{
|
||||
// 0 ~ 1000 은 더미 클라이언트 예약 범위
|
||||
private const long DUMMY_RANGE_MAX = 1000;
|
||||
Reference in New Issue
Block a user