CharacterSelectSystem - jimdroberts/FishMMO GitHub Wiki
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.
-
public bool KeepDeleteData
If true, keeps deleted character data in the database for recovery or auditing.
-
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.
- Attach
CharacterSelectSystem
to the login server and ensure it is initialized before accepting character selection requests. - The system will automatically handle incoming character list, delete, and select broadcasts from clients.
- Character data is managed and results are communicated to the client.
// Example 1: Initialization
characterSelectSystem.InitializeOnce();
// Example 2: Cleanup on shutdown
characterSelectSystem.Destroying();
- 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.