Interface ISceneServerSystem<TConnection>
- Namespace
- FishMMO.Server.Core.World.SceneServer
- Assembly
- FishMMO.Server.dll
Engine-agnostic public API for a Scene Server system responsible for loading and unloading scenes, tracking scene instances, and sending periodic heartbeats (pulses) to connected world servers.
public interface ISceneServerSystem<TConnection> : IServerBehaviour, IServerComponent
Type Parameters
TConnection
Remarks
Implementations must avoid exposing engine-specific types on the public surface. Methods use plain object references for connection handles so different engine/networking implementations can be supported. Thread-safety and lifetime semantics (for example when unloading during shutdown) are implementation details but should be documented by concrete implementations.
Properties
PulseRate
Pulse/heartbeat rate, in seconds. Controls how frequently the system sends status updates to world servers.
float PulseRate { get; }
Property Value
WorldSceneDetailsCache
Gets the world scene details cache for fast lookups of scene instance info.
WorldSceneDetailsCache WorldSceneDetailsCache { get; }
Property Value
Methods
AdjustSceneCharacterCount(long, string, long, int)
Adjusts the tracked character count for a scene instance.
void AdjustSceneCharacterCount(long worldServerID, string sceneName, long sceneID, int amount)
Parameters
worldServerIDlongWorld server that owns the scene instance.
sceneNamestringScene name.
sceneIDlongScene row ID identifying the instance.
amountintAmount to adjust by.
Remarks
Exposed so the character system can keep a scene populated while it holds a combat-logout body. Those bodies are removed from the connection maps the count is otherwise derived from, so without this a scene containing only unattended bodies reports itself empty — it becomes a stale-pulse candidate for unload, and the world server sees capacity that is not really there.
CloseInstance(long, string)
Closes an instance: returns everyone inside it to the open world, then unloads it.
void CloseInstance(long sceneID, string reason)
Parameters
sceneIDlongScene row of the instance to close.
reasonstringWhy it is closing, for diagnostics and player messaging.
Remarks
The correct way to end an instance that still has occupants. UnloadScene(long) destroys the scene outright, which is safe only for one that is already empty — the stale sweep's case. Anything that closes an instance on the server's terms, whether a lifetime cap expiring or a party leader asking, has to go through here so the characters inside are saved, released and re-routed rather than having the ground taken from under them.
NoteDeliberateInstanceExit(long, string, long)
Records that an instance's occupant left by choice rather than by losing its connection, so an instance emptied this way is reclaimed immediately instead of being held for the idle timeout.
void NoteDeliberateInstanceExit(long worldServerID, string sceneName, long sceneID)
Parameters
worldServerIDlongWorld server ID.
sceneNamestringInstance scene name.
sceneIDlongScene row ID identifying the instance.
Remarks
Call AFTER the departure has been debited from the instance's population. See VacatedDeliberately.
TryGetInstanceExpiry(long, out DateTime)
When an instance will close on its own, if it is time-bounded.
bool TryGetInstanceExpiry(long sceneID, out DateTime expiresUtc)
Parameters
Returns
- bool
falsefor a scene this server does not host, an open-world scene, or one whose creation time was never recorded — none of which have an expiry to report.
Remarks
The lifetime cap is configuration this system owns, so the answer is derived here rather than by making every caller read the key and repeat the arithmetic — which is how two places end up disagreeing about when a dungeon ends.
TryGetSceneInstanceDetails(long, string, long, out ISceneInstanceDetails)
Attempts to retrieve instance details for the specified scene instance.
bool TryGetSceneInstanceDetails(long worldServerID, string sceneName, long sceneID, out ISceneInstanceDetails instanceDetails)
Parameters
worldServerIDlongThe id of the world server that owns the scene.
sceneNamestringThe canonical name of the scene.
sceneIDlongThe scene row ID identifying the instance. See SceneID.
instanceDetailsISceneInstanceDetailsWhen this method returns
true, contains the instance details.
Returns
- bool
trueif the instance was found; otherwisefalse.
TryLoadSceneForConnection(TConnection, ISceneInstanceDetails)
Ensures the specified scene instance is loaded and associates the provided connection with that instance.
bool TryLoadSceneForConnection(TConnection connection, ISceneInstanceDetails instance)
Parameters
connectionTConnectionAn engine-agnostic connection object representing the client/peer.
instanceISceneInstanceDetailsThe instance details describing which scene to load/join.
Returns
- bool
truewhen the scene was successfully loaded/associated; otherwisefalse.
UnloadScene(long)
Unloads the scene with the given handle, releasing any associated resources and notifying world servers as appropriate. If the handle is unknown this method should be a no-op.
void UnloadScene(long sceneID)
Parameters
sceneIDlongThe scene row ID of the instance to unload.
UnloadSceneForConnection(TConnection, string)
Removes the given connection from the named scene. If the connection is the last participant the implementation may choose to unload the scene instance.
void UnloadSceneForConnection(TConnection connection, string sceneName)
Parameters
connectionTConnectionThe connection to remove.
sceneNamestringThe canonical scene name from which to remove the connection.