CharacterSelectSystem - jimdroberts/FishMMO GitHub Wiki

Description

CharacterSelectSystem handles character selection, deletion, and list requests on the server in FishMMO. It manages character data for accounts and communicates results to the client.


API Access

Fields

  • public bool KeepDeleteData

    If true, keeps deleted character data in the database for recovery or auditing.

Methods

  • public override void InitializeOnce()

    Initializes the character select system, registering broadcast handlers for character list, delete, and select requests.

  • public override void Destroying()

    Cleans up the character select system, unregistering broadcast handlers for character list, delete, and select requests.

  • private void OnServerCharacterRequestListBroadcastReceived(NetworkConnection conn, CharacterRequestListBroadcast msg, Channel channel)

    Handles broadcast to request the list of available characters for the account, queries the database and sends the list to the client. Parameters: - NetworkConnection conn: Network connection of the client. - CharacterRequestListBroadcast msg: Message requesting the character list. - Channel channel: Network channel used for the broadcast.

  • private void OnServerCharacterDeleteBroadcastReceived(NetworkConnection conn, CharacterDeleteBroadcast msg, Channel channel)

    Handles broadcast to delete a character for the account, updates the database and notifies the client. Parameters: - NetworkConnection conn: Network connection of the client. - CharacterDeleteBroadcast msg: Message requesting character deletion. - Channel channel: Network channel used for the broadcast.

  • private void OnServerCharacterSelectBroadcastReceived(NetworkConnection conn, CharacterSelectBroadcast msg, Channel channel)

    Handles broadcast to select a character for the account, updates the database and sends the world server list to the client. Parameters: - NetworkConnection conn: Network connection of the client. - CharacterSelectBroadcast msg: Message requesting character selection. - Channel channel: Network channel used for the broadcast.


Basic Usage

Setup

  1. Attach CharacterSelectSystem to the login server and ensure it is initialized before accepting character selection requests.
  2. The system will automatically handle incoming character list, delete, and select broadcasts from clients.
  3. Character data is managed and results are communicated to the client.

Example

// Example 1: Initialization
characterSelectSystem.InitializeOnce();

// Example 2: Cleanup on shutdown
characterSelectSystem.Destroying();

Best Practices

  • Always validate account and character existence before processing requests.
  • Use KeepDeleteData to control whether deleted character data is retained for auditing.
  • Clean up broadcast handlers on shutdown to prevent resource leaks.
  • Ensure secure and consistent logic for character management operations.
⚠️ **GitHub.com Fallback** ⚠️