NamingSystem - jimdroberts/FishMMO GitHub Wiki

Description

The NamingSystem is a server-side system in FishMMO responsible for resolving names and IDs for characters and guilds. It registers and handles network broadcasts for naming and reverse naming requests, checks local server caches, and falls back to database lookups as needed. The system ensures that all name and ID resolutions are validated and synchronized between the server, database, and client.


API Access

Methods

  • public override void InitializeOnce()

    Initializes the naming system, registering broadcast handlers for naming and reverse naming requests.

  • public override void Destroying()

    Cleans up the naming system, unregistering broadcast handlers.

  • private void OnServerNamingBroadcastReceived(NetworkConnection conn, NamingBroadcast msg, Channel channel)

    Handles incoming naming requests from clients, resolves names by ID for characters and guilds. Checks local cache first, then falls back to database lookup. conn (NetworkConnection): Network connection of the requesting client. msg (NamingBroadcast): Message containing the type and ID to resolve. channel (Channel): Network channel used for the broadcast.

  • public void SendNamingBroadcast(NetworkConnection conn, NamingSystemType type, long id, string name)

    Sends a naming broadcast to the specified connection, providing the resolved name for the given ID and type. conn (NetworkConnection): Network connection to send the broadcast to. type (NamingSystemType): Type of naming system (character, guild, etc.). id (long): ID of the object to resolve. name (string): Resolved name to send.

  • private void OnServerReverseNamingBroadcastReceived(NetworkConnection conn, ReverseNamingBroadcast msg, Channel channel)

    Handles incoming reverse naming requests from clients, resolves IDs by name for characters. Checks local cache first, then falls back to database lookup. Notifies client if not found. conn (NetworkConnection): Network connection of the requesting client. msg (ReverseNamingBroadcast): Message containing the type and name to resolve. channel (Channel): Network channel used for the broadcast.

  • public void SendReverseNamingBroadcast(NetworkConnection conn, NamingSystemType type, string nameLowerCase, long id, string name)

    Sends a reverse naming broadcast to the specified connection, providing the resolved ID and name for the given type and name. conn (NetworkConnection): Network connection to send the broadcast to. type (NamingSystemType): Type of naming system (character, guild, etc.). nameLowerCase (string): Lowercase name to resolve. id (long): Resolved ID to send. name (string): Resolved name to send.


Basic Usage

Setup

  1. Requires the server to be running and the naming system to be initialized as part of the server startup.
  2. The system automatically registers broadcast handlers for naming and reverse naming requests.
  3. No manual registration is required unless extending or customizing naming logic.

Example

// Example 1: Resolving a character name by ID (server-side)
// This is handled automatically by the system when a NamingBroadcast is received from a client.
// No manual invocation is required unless extending or customizing the logic.

// Example 2: Resolving a character ID by name (server-side)
// This is handled automatically by the system when a ReverseNamingBroadcast is received from a client.
// No manual invocation is required unless extending or customizing the logic.

Best Practices

  • Always validate all naming and reverse naming requests to prevent exploits and errors.
  • Use the provided broadcast handlers to extend or customize naming logic if needed.
  • Ensure all name and ID resolutions are properly synchronized between the server, database, and client.
  • Avoid direct manipulation of naming data outside of the provided interfaces and system methods.
⚠️ **GitHub.com Fallback** ⚠️