GrpcOpenMatchClient

A GrpcOpenMatchClient represents the gRPC implementation of the Open Match frontend. The implementation is based on the official Protobufs released with Open Match. Each platform only needs one implementation of the Open Match Client, but does not have to worry about selecting the best implementation. Instead, the factory method specifies the implementation. All implementations fully comply with the Open Match specification.

When creating an instance of this implementation, the corresponding network channel is dynamically assembled for this purpose. The host is obtained through the environment variable FRONTEND_HOST_ENV_KEY, and the port is obtained through the environment variable FRONTEND_PORT_ENV_KEY, if any value has been set for these keys. The corresponding stubs for coroutine-based communication with the interface are instantiated for the channel to the supplied frontend. No action is taken by creating this instance, and communication with the external interface is not initiated.

Parameters

host

The host, under which the gRPC server of the Open Match frontend can be reached and that will therefore be used to establish the connection.

port

The port, under which the gRPC server of the Open Match frontend can be reached and that will therefore be used to establish the connection.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The host of the external interface of the Open Match frontend, that will be used to establish the connection.

Link copied to clipboard
val port: Int

The port of the external interface of the Open Match frontend, that will be used to establish the connection.

Functions

Link copied to clipboard
open suspend override fun acknowledgeBackfill(backfillId: String, assignment: Messages.Assignment): Frontend.AcknowledgeBackfillResponse

Notifies Open Match about the Assignment or address information of the respective game server. This starts the assignment process and searches for tickets that can be assigned to this Backfill. The retrieved tickets are included in the return value and can be connected to the corresponding server. If the corresponding Backfill does not exist, a NoSuchElementException is thrown.

Link copied to clipboard
open override fun close()

Closes all open resources that are associated with the Open Match Client. After this operation, this instance of the Open Match Client may no longer be used, as all connections are no longer usable. This method is idempotent and can therefore be called any number of times without changing its behaviour. It is guaranteed, that after this call all open connections and allocated resources will be closed or released. Although not all implementations have such resources, the method should still always be called (for example, within a Try-With_Resources block or a use method) to cleanly terminate resource usage.

Link copied to clipboard
open suspend override fun createBackfill(template: TicketTemplate): Messages.Backfill

Creates a new Backfill within Open Match with the metadata of a specific TicketTemplate. The identifier and the creation moment are generated and assigned by Open Match. The game server assignment is subsequently determined by acknowledgeBackfill.

Link copied to clipboard
open suspend override fun createTicket(template: TicketTemplate): Messages.Ticket

Creates a new Ticket within Open Match with the metadata of a specific TicketTemplate. The identifier and creation moment are generated and assigned by Open Match. The game server assignment is determined by the Director after this Ticket has been assigned to a match. The status of the assignment can be observed using watchAssignments.

Link copied to clipboard
open suspend override fun deleteBackfill(backfillId: String)

Deletes an existing Backfill with a specific identifier within Open Match. If this Backfill has already been assigned to a match, this operation has no effect. However, the Backfill is immediately excluded from further assignment considerations. If no Backfill with such an ID exists, this method does not cause any changes within Open Match.

Link copied to clipboard
open suspend override fun deleteTicket(ticketId: String)

Deletes an existing Ticket with a specific identifier within Open Match. If this Ticket has already been assigned to a match, this operation has no effect. However, the Ticket is immediately excluded from further match creation considerations. If no Ticket with such an ID exists, this method does not cause any changes within Open Match.

Link copied to clipboard
open suspend override fun getBackfill(backfillId: String): Messages.Backfill?

Retrieves an existing Backfill with a specific identifier within Open Match and returns it. If no Backfill exists with this ID, null is returned instead. The Backfill is always queried in its current valid state from Open Match, so it may contain changes that were not made by this client.

Link copied to clipboard
open suspend override fun getTicket(ticketId: String): Messages.Ticket?

Retrieves an existing Ticket with a specific identifier within Open Match and returns it. If no Ticket exists with this ID, null is returned instead. The Ticket is always queried in its currently valid state from Open Match, and therefore it may contain changes not made by this client.

Link copied to clipboard
open suspend override fun updateBackfill(backfill: Messages.Backfill): Messages.Backfill

Updates the metadata associated with a Backfill and returns the new Backfill. The passed Backfill must have the identifier set. The metadata from the object is completely overwritten, replacing the current metadata of the Backfill. The creation moment is not updated, but the generation is incremented. This returns all tickets waiting on this Backfill back to the active pool, making them no longer pending.

Link copied to clipboard
open override fun watchAssignments(ticketId: String): Flow<Frontend.WatchAssignmentsResponse>

Subscribes to changes of the game server assignment of an individual Ticket with a specific identifier. The Flow receives a new item, whenever a change is made to the Assignment. For changes triggered by this client as well as for external changes applied by other clients or other components of the Open Match matchmaking process. The item always contains the most recent state of the Assignment.