subscribeServiceResponse

fun <TService : UnifiedService, TNotification : GeneratedMessage.Builder<TNotification>> subscribeServiceResponse(serviceClass: Class<TService>, notificationClass: Class<TNotification>, callbackFunc: Consumer<ServiceMethodResponse<TNotification>>): Closeable

Registers a callback to receive service responses from Steam's unified messaging system.

This method creates a service subscription that listens for specific responses from a Steam service. When a response is received, it validates the response type and forwards it to the provided callback function if the types match. Unlike notifications, responses are typically used for request-response patterns in the Steam API.

Return

A Closeable subscription. Call Closeable.close to unsubscribe and clean up resources

Parameters

TService

The type of Steam service to subscribe to (e.g., GameNotificationsClient)

TNotification

The type of response message to receive

serviceClass

The class object representing the Steam service

notificationClass

The class object representing the response type

callbackFunc

The callback function to be invoked when matching responses are received

See also

Example usage in Kotlin: val subscription = manager.subscribeServiceResponse( Player::class.java, CPlayer_GetGameBadgeLevels_Response.Builder::class.java ) { response -> println("Badge level: ${response.body.playerLevel}") }

Example usage in Java: Closeable subscription = manager.subscribeServiceResponse( Player.class, CPlayer_GetGameBadgeLevels_Response.Builder.class, response -> { System.out.println("Badge level: " + response.getBody().getPlayerLevel()); } );