watchAssignments

abstract fun watchAssignments(ticketId: String): Flow<Frontend.WatchAssignmentsResponse>(source)

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.

To unsubscribe from the updates, the returned Flow can be cancelled, and the underlying stream will be closed and cleaned up. It can be started to subscribe again after that, by invoking this method again and obtaining a new, independent Flow.

Since the stream (if not terminated beforehand) runs indefinitely, it may delay the shutdown of the Client, and it should be terminated beforehand. To avoid waiting for the maximum timeout, all streams should be closed beforehand. If there are still open streams, an error will be published in the Flow, and the underlying stream in gRPC will be terminated.

Return

A Flow of updated assignment resources that returns a new element every time there was an update to the underlying data. Always contains the whole dataset and not only the modified fields.

See also

Samples


fun main() { 
   //sampleStart 
   // host and port are supplied by the default environment variables
val client = GrpcOpenMatchClient()

// watch the ticket assignments and act on updates until a condition is met
client.watchAssignments("ticket-id")
    .takeWhile { !initialized }
    .collect { // do something } 
   //sampleEnd
}