Table of Contents

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

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

partyId long

The party to inspect.

cancellationToken CancellationToken

Token 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.

PersistAsync(CharacterPartyData, int, CancellationToken)

Persists the provided party membership data, enforcing capacity limits.

Task<DatabaseResult> PersistAsync(CharacterPartyData partyData, int maxCapacity, CancellationToken cancellationToken = default)

Parameters

partyData CharacterPartyData

The party membership data to persist.

maxCapacity int

The maximum number of members allowed in the party.

cancellationToken CancellationToken

Token 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

characterId long

The character ID.

partyId long

The party ID.

rank byte

The new rank.

incomingVersion long

The authoritative, monotonic version for this update operation.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

A DatabaseResult indicating success or failure.