Files
systemrevivalserver/Networking/Messages/OpCodes.cs
T
2026-02-17 11:18:55 -05:00

177 lines
5.6 KiB
C#

namespace Server.Networking.Messages;
/// <summary>
/// Network message operation codes for client-server communication
/// </summary>
public static class OpCodes
{
/// <summary>
/// Echo test message - server echoes back the received payload
/// </summary>
public const int ECHO = 1;
/// <summary>
/// Server -> Client: Keepalive ping message to prevent idle timeout
/// Client should respond with PONG to reset idle timer
/// </summary>
public const int PING = 2;
/// <summary>
/// Client -> Server: Response to PING message
/// Indicates client is still alive and responsive
/// </summary>
public const int PONG = 3;
// ===== Authentication (100-119) =====
/// <summary>
/// Client -> Server: Register new account
/// Payload: { username: string, password: string }
/// </summary>
public const int AUTH_REGISTER = 100;
/// <summary>
/// Server -> Client: Registration result
/// Payload: { success: bool, message: string, accountId?: int }
/// </summary>
public const int AUTH_REGISTER_RESULT = 101;
/// <summary>
/// Client -> Server: Login with username and password
/// Payload: { username: string, password: string }
/// </summary>
public const int AUTH_LOGIN = 110;
/// <summary>
/// Server -> Client: Login result
/// Payload: { success: bool, message: string, token?: string }
/// </summary>
public const int AUTH_LOGIN_RESULT = 111;
/// <summary>
/// Client -> Server: Authenticate using stored token
/// Payload: { token: string }
/// </summary>
public const int AUTH_WITH_TOKEN = 112;
/// <summary>
/// Server -> Client: Token authentication result
/// Payload: { success: bool, message: string }
/// </summary>
public const int AUTH_WITH_TOKEN_RESULT = 113;
// ===== Character Management (200-219) =====
/// <summary>
/// Client -> Server: Create new character
/// Payload: { name: string }
/// </summary>
public const int CHAR_CREATE = 202;
/// <summary>
/// Server -> Client: Character creation result
/// Payload: { success: bool, message: string, character?: object }
/// </summary>
public const int CHAR_CREATE_RESULT = 203;
/// <summary>
/// Client -> Server: Select character to play
/// Payload: { characterId: int }
/// </summary>
public const int CHAR_SELECT = 204;
/// <summary>
/// Server -> Client: Character selection result
/// Payload: { success: bool, message: string }
/// </summary>
public const int CHAR_SELECT_RESULT = 205;
// ===== World/Overworld (700-719) =====
/// <summary>
/// Client -> Server: Request to spawn in world after character selection
/// </summary>
public const int WORLD_SPAWN_REQUEST = 700;
/// <summary>
/// Server -> Client: Spawn notification (your own character or other players joining)
/// </summary>
public const int WORLD_SPAWN = 701;
/// <summary>
/// Server -> Client: Despawn notification (player leaving)
/// </summary>
public const int WORLD_DESPAWN = 702;
/// <summary>
/// Client -> Server: Player input (movement, actions)
/// Sent at ~20 Hz or per tick
/// </summary>
public const int WORLD_INPUT = 710;
/// <summary>
/// Server -> Client: World state snapshot
/// Sent at ~10-20 Hz
/// </summary>
public const int WORLD_STATE = 711;
/// <summary>
/// Server -> Client: Live chunk delta (tile/object/npc/mob added/removed/changed)
/// Pushed immediately when an admin edits the world, to all players viewing that chunk.
/// </summary>
public const int WORLD_CHUNK_DELTA = 712;
// ===== World Combat (720-739) =====
/// <summary>Server -> Client: Combat state update (mob states, damage events, deaths)</summary>
public const int WORLD_COMBAT_STATE = 720;
/// <summary>Client -> Server: Player attacks a mob, player, or object in the world</summary>
public const int WORLD_ATTACK = 721;
/// <summary>Client -> Server: Request loot from dead world mob</summary>
public const int WORLD_MOB_LOOT_REQUEST = 722;
/// <summary>Server -> Client: Loot contents from world mob</summary>
public const int WORLD_MOB_LOOT_RESULT = 723;
// ===== World NPC (740-749) =====
/// <summary>Client -> Server: Interact with world NPC</summary>
public const int WORLD_NPC_INTERACT = 740;
/// <summary>Server -> Client: NPC interaction state (dialog/shop)</summary>
public const int WORLD_NPC_INTERACT_STATE = 741;
/// <summary>Client -> Server: Select dialog option</summary>
public const int WORLD_NPC_DIALOG_SELECT = 742;
/// <summary>Server -> Client: Dialog result</summary>
public const int WORLD_NPC_DIALOG_RESULT = 743;
/// <summary>Client -> Server: NPC shop buy/sell</summary>
public const int WORLD_NPC_SHOP_ACTION = 744;
/// <summary>Server -> Client: Shop action result</summary>
public const int WORLD_NPC_SHOP_RESULT = 745;
// ===== World Object (750-759) =====
/// <summary>Client -> Server: Interact with world object</summary>
public const int WORLD_OBJECT_INTERACT = 750;
/// <summary>Server -> Client: Object interaction result</summary>
public const int WORLD_OBJECT_INTERACT_RESULT = 751;
/// <summary>Server -> Client: Object state change broadcast</summary>
public const int WORLD_OBJECT_STATE = 752;
// ===== Error Messages (900-999) =====
/// <summary>
/// Server -> Client: General error message
/// Payload: { error: string }
/// </summary>
public const int ERROR = 900;
}