Interface ICharacterPartyService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
Service interface for managing a character's party membership state.
public interface ICharacterPartyService : ICountByKeyAction<long>, IDeleteByKeyVersionedAction<long>, IFetchByKeyAction<long, CharacterPartyData?>, IFetchManyByKeyAction<long, CharacterPartyData>
- Inherited Members
Remarks
Party membership updates should be version-gated via the logical Version
so stale updates are rejected and newer authoritative updates win.
Methods
FetchManyAsync(long[], CancellationToken)
Fetches the rosters of several parties in one query.
Task<DatabaseResult<IReadOnlyDictionary<long, IReadOnlyList<CharacterPartyData>>>> FetchManyAsync(long[] partyIds, CancellationToken cancellationToken = default)
Parameters
partyIdslong[]The parties to read. Non-positive and repeated IDs are ignored.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult<IReadOnlyDictionary<long, IReadOnlyList<CharacterPartyData>>>>
One entry per distinct requested party, ALWAYS present: a party with no membership rows maps to an empty list, exactly as
FetchManyAsync(long)answers for it. A caller can therefore tell "read, and empty" from "not read" by the result alone.
Remarks
For the scene server's party update pump, which used to read each changed party's roster in its own round trip. A login wave that touches two hundred parties in one second then cost two hundred serial queries before any of them could be delivered, and the pump's in-flight guard held every later tick behind them.
FetchOnlineMemberIdsAsync(long, CancellationToken)
Returns the party's members who currently hold a live session.
Task<DatabaseResult<IReadOnlyList<long>>> FetchOnlineMemberIdsAsync(long partyId, CancellationToken cancellationToken = default)
Parameters
partyIdlongThe party to inspect.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult<IReadOnlyList<long>>>
The character IDs of members with a live session; empty when none are online.
Remarks
Exists so party leadership can be repaired convergently rather than only on the events that break it. A scene server knows which characters IT hosts and nothing about the rest of the shard, so an absent leader — one who disconnected, or crashed, or whose server died — is invisible to every server that could do something about it. Without this the party is stuck: it HAS a leader, so nothing that merely counts leaders sees a problem, and that leader is not there to invite, kick, promote, or close the instance the party is holding open.
"Online" is the same definition the account session checks use, and it is the strict one on purpose. A lapsed lease does not count, which is what lets a party recover from a scene server dying rather than waiting for it to come back. A character running out a combat-logout timer does not count either: its session is still claimed so its body stays authoritative, but the player is gone, and leadership must follow the player.
FetchOnlineMemberIdsAsync(long[], CancellationToken)
Returns, for each of several parties, the members who currently hold a live session.
Task<DatabaseResult<IReadOnlyDictionary<long, IReadOnlyList<long>>>> FetchOnlineMemberIdsAsync(long[] partyIds, CancellationToken cancellationToken = default)
Parameters
partyIdslong[]The parties to inspect. Non-positive and repeated IDs are ignored.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult<IReadOnlyDictionary<long, IReadOnlyList<long>>>>
One entry per distinct requested party, ALWAYS present; empty when nobody in it is online.
Remarks
The bulk form of FetchOnlineMemberIdsAsync(long, CancellationToken), with the same definition of "online" — the single-party form is answered by this one, so the two cannot drift apart. Grouped by the membership row's own party, so a character who moved between parties is reported under the party the database says they are in now.
PersistAsync(CharacterPartyData, int, CancellationToken)
Persists the provided party membership data, enforcing capacity limits.
Task<DatabaseResult> PersistAsync(CharacterPartyData partyData, int maxCapacity, CancellationToken cancellationToken = default)
Parameters
partyDataCharacterPartyDataThe party membership data to persist.
maxCapacityintThe maximum number of members allowed in the party.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult>
A DatabaseResult indicating success or failure.
UpdateRankAsync(long, long, byte, long, CancellationToken)
Updates a character's party rank if incomingVersion is newer.
Task<DatabaseResult> UpdateRankAsync(long characterId, long partyId, byte rank, long incomingVersion, CancellationToken cancellationToken = default)
Parameters
characterIdlongThe character ID.
partyIdlongThe party ID.
rankbyteThe new rank.
incomingVersionlongThe authoritative, monotonic version for this update operation.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult>
A DatabaseResult indicating success or failure.