Class CharacterPersistenceParticipant
- Namespace
- FishMMO.Server.Implementation.World.SceneServer
- Assembly
- FishMMO.Server.dll
One feature's part of a character's save and load: what it fetches as the character loads, how it puts that on the character, what it captures when the character is saved, and how it writes that. The character save and load call every installed participant and name none, so a feature that saves data brings its participant with it and leaves the save path alone.
public abstract class CharacterPersistenceParticipant
- Inheritance
-
CharacterPersistenceParticipant
- Derived
- Inherited Members
Remarks
Installed by declaring it on its assembly: [assembly: CharacterPersistence(typeof(MyParticipant))].
The save path's guarantees hold for every participant without each restating them: rows are captured only with the character's session claim, every write quotes the claims its rows were captured under, the hand-off paths write sequentially with bounded retry before the release, and the periodic path keeps a row's dirty mark until a write is confirmed. A participant's part is to capture only dirty rows, bump their versions as it captures, and clear the marks only after a confirmed write.
Properties
Name
The feature's name, for the log ("achievements").
public abstract string Name { get; }
Property Value
Methods
Apply(ICharacter, object)
Puts what FetchAsync(ICharacterPersistenceHost, long) returned on the character, restored as persisted (nothing dirty). Main thread, after the character's Core entity exists and before it spawns.
public abstract void Apply(ICharacter character, object fetched)
Parameters
characterICharacterfetchedobject
Capture(ICharacter, CharacterRows)
Captures the character's dirty rows into rows, bumping their versions. Main thread.
public abstract void Capture(ICharacter character, CharacterRows rows)
Parameters
characterICharacterrowsCharacterRows
CreateRows()
An empty set of this participant's rows.
public abstract CharacterRows CreateRows()
Returns
FetchAsync(ICharacterPersistenceHost, CharacterData)
Fetches the character's saved state, knowing the character's own row (its world server, its scene). Worker thread, during the load. The load calls this one; by default it is FetchAsync(ICharacterPersistenceHost, long).
public virtual Task<CharacterFetch> FetchAsync(ICharacterPersistenceHost host, CharacterData character)
Parameters
hostICharacterPersistenceHostcharacterCharacterData
Returns
FetchAsync(ICharacterPersistenceHost, long)
Fetches the character's saved state. Worker thread, during the load.
public abstract Task<CharacterFetch> FetchAsync(ICharacterPersistenceHost host, long characterID)
Parameters
hostICharacterPersistenceHostcharacterIDlong
Returns
SaveAsync(ICharacterPersistenceHost, CharacterRows, IReadOnlyCollection<CharacterSessionLeaseData>)
Writes rows, quoting claims, and clears the written rows' dirty
marks on the main thread once the write is confirmed. Worker thread.
public abstract Task<bool> SaveAsync(ICharacterPersistenceHost host, CharacterRows rows, IReadOnlyCollection<CharacterSessionLeaseData> claims)
Parameters
hostICharacterPersistenceHostrowsCharacterRowsclaimsIReadOnlyCollection<CharacterSessionLeaseData>