132 lines
3.9 KiB
C#
132 lines
3.9 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;
|
|
|
|
// ===== Error Messages (900-999) =====
|
|
|
|
/// <summary>
|
|
/// Server -> Client: General error message
|
|
/// Payload: { error: string }
|
|
/// </summary>
|
|
public const int ERROR = 900;
|
|
}
|