game / pragma.multiplayer / MultiplayerService /

MultiplayerService #

internal class MultiplayerService(pragmaNode: PragmaNode, instanceId: <ERROR CLASS>, partyClient: PartyClient = PartyClient(), gameInstanceClient: GameInstanceClient = GameInstanceClient(), cache: MultiplayerCache = MultiplayerCache()) : DistributedService, ConfigHandler<MultiplayerConfig>

The MultiplayerService handles the routing between players and their various multiplayer states.

Game flow services, like the PartyService, have their endpoints routed based on their entity id (e.g. PartyId). Player clients may lose track of their entity ids due to disconnecting or desyncing, making it difficult to rely on the client as a source of truth.

This service is responsible for caching various multiplayer states from the game flow services, so it can provide a consistent routing mechanism and act as the source of truth for the client.

Constructors #

MultiplayerService

fun MultiplayerService(pragmaNode: PragmaNode, instanceId: <ERROR CLASS>, partyClient: PartyClient = PartyClient(), gameInstanceClient: GameInstanceClient = GameInstanceClient(), cache: MultiplayerCache = MultiplayerCache())

Functions #

NameSummary

getCachedMultiplayerDataServiceV1

suspend fun getCachedMultiplayerDataServiceV1(session: ServiceSession, request: MultiplayerRpc.GetCachedMultiplayerDataServiceV1Request): MultiplayerRpc.GetCachedMultiplayerDataServiceV1Response

Gets the cached multiplayer data for a given player.

getCacheInfoOperatorV1

suspend fun getCacheInfoOperatorV1(session: OperatorSession, request: MultiplayerRpc.GetCacheInfoOperatorV1Request): MultiplayerRpc.GetCacheInfoOperatorV1Response

Queries cached multiplayer data by player id.

initializeGameInstanceV1

suspend fun initializeGameInstanceV1(session: PlayerSession, request: MultiplayerRpc.InitializeGameInstanceV1Request): MultiplayerRpc.InitializeGameInstanceV1Response

Retrieves latest game instance state. Used to synchronize the client to the platform.

initializePartyV1

suspend fun initializePartyV1(session: PlayerSession, request: MultiplayerRpc.InitializePartyV1Request): MultiplayerRpc.InitializePartyV1Response

Retrieves latest party state. Used to synchronize the client to the platform.

processAllGameInstanceUpdatesV1

suspend fun processAllGameInstanceUpdatesV1(session: ServiceSession, request: MultiplayerRpc.ProcessAllGameInstanceUpdatesV1Request): MultiplayerRpc.ProcessAllGameInstanceUpdatesV1Response

Process the updates provided from the GameInstanceService.

processAllPartyUpdatesV1

suspend fun processAllPartyUpdatesV1(session: ServiceSession, request: MultiplayerRpc.ProcessAllPartyUpdatesV1Request): MultiplayerRpc.ProcessAllPartyUpdatesV1Response

Process the updates provided from the PartyService.

syncGameInstanceV1

suspend fun syncGameInstanceV1(session: PlayerSession, request: MultiplayerRpc.SyncGameInstanceV1Request): MultiplayerRpc.SyncGameInstanceV1Response

Synchronizes latest game instance state. Used to resynchronize the client to the platform.

syncPartyV1

suspend fun syncPartyV1(session: PlayerSession, request: MultiplayerRpc.SyncPartyV1Request): MultiplayerRpc.SyncPartyV1Response

Retrieves latest party state. Used to synchronize the client to the platform.