Ping/Pong
This commit is contained in:
+102
-12
@@ -1,35 +1,125 @@
|
||||
namespace Server.Networking.Messages;
|
||||
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;
|
||||
|
||||
public const int ERROR = 900;
|
||||
|
||||
//public const int CHAR_LIST = 200;
|
||||
//public const int CHAR_LIST_RESULT = 201;
|
||||
|
||||
// ===== 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;
|
||||
|
||||
public const int WORLD_SPAWN_REQUEST = 300; // client -> server (after select)
|
||||
public const int WORLD_SPAWN = 301; // server -> client (your own + others joining)
|
||||
public const int WORLD_DESPAWN = 302; // server -> client
|
||||
|
||||
public const int WORLD_INPUT = 310; // client -> server (per tick or at ~20 Hz)
|
||||
public const int WORLD_STATE = 311; // server -> client (snapshots, ~10–20 Hz)
|
||||
// ===== World/Overworld (300-319) =====
|
||||
|
||||
/// <summary>
|
||||
/// Client -> Server: Request to spawn in world after character selection
|
||||
/// </summary>
|
||||
public const int WORLD_SPAWN_REQUEST = 300;
|
||||
|
||||
/// <summary>
|
||||
/// Server -> Client: Spawn notification (your own character or other players joining)
|
||||
/// </summary>
|
||||
public const int WORLD_SPAWN = 301;
|
||||
|
||||
/// <summary>
|
||||
/// Server -> Client: Despawn notification (player leaving)
|
||||
/// </summary>
|
||||
public const int WORLD_DESPAWN = 302;
|
||||
|
||||
/// <summary>
|
||||
/// Client -> Server: Player input (movement, actions)
|
||||
/// Sent at ~20 Hz or per tick
|
||||
/// </summary>
|
||||
public const int WORLD_INPUT = 310;
|
||||
|
||||
/// <summary>
|
||||
/// Server -> Client: World state snapshot
|
||||
/// Sent at ~10-20 Hz
|
||||
/// </summary>
|
||||
public const int WORLD_STATE = 311;
|
||||
|
||||
// ===== Error Messages (900-999) =====
|
||||
|
||||
/// <summary>
|
||||
/// Server -> Client: General error message
|
||||
/// Payload: { error: string }
|
||||
/// </summary>
|
||||
public const int ERROR = 900;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user