WorldServerSystem - jimdroberts/FishMMO GitHub Wiki
Handles world server registration and heartbeat (pulse) updates in the database. Periodically updates the world server's status and character count, ensuring the server's presence and load are accurately tracked in FishMMO infrastructure.
-
private LocalConnectionState serverState
Current connection state of the server.
-
private long id
Database ID for this world server instance.
-
private bool locked
Indicates whether the world server is locked (not accepting new connections).
-
private float pulseRate
Interval (in seconds) between heartbeat pulses to the database.
-
private float nextPulse
Time remaining until the next heartbeat pulse.
-
public long ID
Gets the database ID for this world server instance.
-
public override void InitializeOnce()
Initializes the world server system, registers the server in the database, and subscribes to connection state events.
-
public override void Destroying()
Called when the system is being destroyed. No custom logic implemented.
-
private void ServerManager_OnServerConnectionState(ServerConnectionStateArgs args)
Handles changes in the server's connection state. args: ServerConnectionStateArgs - Connection state arguments.
-
void LateUpdate()
Unity LateUpdate callback. Periodically sends a heartbeat pulse to the database with the current character count.
- Requires FishNet networking, FishMMO server infrastructure, and a configured database connection.
- Attach the WorldServerSystem to a server GameObject. Ensure database settings are configured in GlobalSettings.
- The system initializes itself on startup, registering with the database and subscribing to connection state events.
- No manual heartbeat management is required; the system automatically updates the database with server status and character count.
// Example 1: Setting up WorldServerSystem
// Attach WorldServerSystem to a server GameObject and ensure dependencies are set up.
void Start()
{
// WorldServerSystem will initialize automatically if attached and enabled.
}
// Example 2: Heartbeat pulse to database
// The system automatically sends heartbeat pulses; no manual invocation is required.
- Ensure database connectivity and GlobalSettings are properly configured before starting the server.
- Use the pulseRate setting to balance database update frequency and server performance.
- Monitor the database for server status and character count to ensure accurate tracking.
- Clean up all event subscriptions on shutdown to prevent resource leaks.