Class WorldServerSystem
- Namespace
- FishMMO.Server.Implementation.World.WorldServer
- Assembly
- FishMMO.Server.dll
Handles world server registration and heartbeat (pulse) updates in the database. Periodically updates the world server's status and character count. Database operations are async to avoid blocking the main thread.
[CreateAssetMenu(fileName = "WorldServerSystem", menuName = "FishMMO/Server/WorldServer/World Server System", order = 1)]
[RequiresDataContainer(typeof(WorldServerSystemRuntimeData))]
[RequiresDataContainer(typeof(AsyncWorkerData))]
public class WorldServerSystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IWorldServerSystem, IServerBehaviour, IServerComponent
- Inheritance
-
ObjectScriptableObjectWorldServerSystem
- Implements
- Inherited Members
-
ScriptableObject.SetDirty()ScriptableObject.CreateInstance<T>()Object.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Properties
PulseRate
Interval (in seconds) between heartbeat pulses to the database.
public float PulseRate { get; }
Property Value
Methods
InitializeOnce()
Initializes the world server system, validates dependencies, registers this world server in the database, and starts periodic pulse callbacks.
public override ServerComponentInitializationStatus InitializeOnce()
Returns
- ServerComponentInitializationStatus
The initialization status.
InitializeOnceAsync(CancellationToken)
Initializes the system and registers it in the database without blocking the Unity main thread.
public override Task<ServerComponentInitializationStatus> InitializeOnceAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
Remarks
Awaits here deliberately capture Unity's SynchronizationContext (no
ConfigureAwait(false)), so execution resumes on the main thread and the Unity
and FishNet APIs used below stay legal.
OnDeinitialize()
Called when the system is being destroyed. Deregisters the world server from the database and unregisters periodic callbacks.
public override void OnDeinitialize()
Pulse(int)
Sends a heartbeat/pulse update with the current character count.
public void Pulse(int characterCount)
Parameters
characterCountintCurrent character count.
RegisterAsync(string, ushort, int, CancellationToken)
Registers the world server in the database without blocking the Unity main thread.
public Task<bool> RegisterAsync(string serverAddress, ushort port, int characterCount, CancellationToken cancellationToken = default)
Parameters
serverAddressstringAddress string.
portushortPort number.
characterCountintCharacter count to register.
cancellationTokenCancellationTokenCancelled when the server shuts down mid-startup.