feat : 서버 실패 코드 메시지 기능 추가

This commit is contained in:
qornwh1
2026-03-08 22:03:06 +09:00
parent 06741f2a55
commit 3188dbeb3d
5 changed files with 69 additions and 2 deletions

View File

@@ -516,6 +516,31 @@ public class DamagePacket
}
}
// ============================================================
// 에러
// ============================================================
public enum ErrorCode : int
{
// 파티 (10021~)
PARTY_ALREADY_IN_PARTY = 10021,
PARTY_JOIN_FAILED = 10022,
PARTY_NOT_IN_PARTY = 10023,
PARTY_DELETE_FAILED = 10024,
}
// ERROR (서버 -> 클라)
[ProtoContract]
public class ErrorPacket
{
[ProtoMember(1)]
public ErrorCode Code
{
get;
set;
}
}
// ============================================================
// 파티
// ============================================================

View File

@@ -52,7 +52,10 @@ public enum PacketCode : ushort
UPDATE_PARTY,
// 파티 참가/탈퇴/생성/해산 요청 (클라 -> 서버)
REQUEST_PARTY
REQUEST_PARTY,
// 요청 실패 응답 (서버 -> 클라)
ERROR = 9999
}
public class PacketHeader

View File

@@ -484,6 +484,7 @@ public class GameServer : ServerBase
{
if (!pm.CreateParty(hashKey, req.PartyName, out PartyInfo? party))
{
SendError(peer, ErrorCode.PARTY_ALREADY_IN_PARTY);
return;
}
@@ -503,6 +504,7 @@ public class GameServer : ServerBase
{
if (!pm.JoinParty(hashKey, req.PartyId, out PartyInfo? party))
{
SendError(peer, ErrorCode.PARTY_JOIN_FAILED);
return;
}
@@ -521,6 +523,7 @@ public class GameServer : ServerBase
{
if (!pm.LeaveParty(hashKey, out PartyInfo? party))
{
SendError(peer, ErrorCode.PARTY_NOT_IN_PARTY);
return;
}
@@ -544,6 +547,7 @@ public class GameServer : ServerBase
{
if (!pm.DeleteParty(hashKey, req.PartyId, out PartyInfo? party))
{
SendError(peer, ErrorCode.PARTY_DELETE_FAILED);
return;
}
@@ -560,6 +564,13 @@ public class GameServer : ServerBase
}
}
private void SendError(NetPeer peer, ErrorCode code)
{
ErrorPacket err = new ErrorPacket { Code = code };
byte[] data = PacketSerializer.Serialize<ErrorPacket>((ushort)PacketCode.ERROR, err);
SendTo(peer, data);
}
private void BroadcastToUsers(IEnumerable<int> userIds, byte[] data, DeliveryMethod method = DeliveryMethod.ReliableOrdered)
{
foreach (int userId in userIds)

View File

@@ -516,6 +516,31 @@ public class DamagePacket
}
}
// ============================================================
// 에러
// ============================================================
public enum ErrorCode : int
{
// 파티 (10021~)
PARTY_ALREADY_IN_PARTY = 10021,
PARTY_JOIN_FAILED = 10022,
PARTY_NOT_IN_PARTY = 10023,
PARTY_DELETE_FAILED = 10024,
}
// ERROR (서버 -> 클라)
[ProtoContract]
public class ErrorPacket
{
[ProtoMember(1)]
public ErrorCode Code
{
get;
set;
}
}
// ============================================================
// 파티
// ============================================================

View File

@@ -52,7 +52,10 @@ public enum PacketCode : ushort
UPDATE_PARTY,
// 파티 참가/탈퇴/생성/해산 요청 (클라 -> 서버)
REQUEST_PARTY
REQUEST_PARTY,
// 요청 실패 응답 (서버 -> 클라)
ERROR = 9999
}
public class PacketHeader