PubSubSubscribeOptions

class PubSubSubscribeOptions(val oldMessageLimit: Int? = null, val realtimeOverflow: RealtimeOverflow = RealtimeOverflow.QUEUE, val maxQueue: Int? = null, val newMessageLimit: Int? = null)

Bounds how much history a subscription replays and how fast live messages reach it. Pass one to Room.PubSub.subscribe; passing none replays the whole history at the server's own pace.

These options do not change how messages are delivered. History arrives in server-paced batches on PubSubMessageListener.onOldMessagesReceived either way, and live batching is a server setting rather than a subscribe option.

A room whose server supplies no dedicated pubsub endpoint ignores all of it: the options are still validated, then the whole history arrives as one batch and nothing is paced.

val options = PubSubSubscribeOptions(oldMessageLimit = 100, maxQueue = 70)
room.pubSub.subscribe("CHAT", listener, options)

Out-of-range values are not rejected here; subscribe throws ERROR_INVALID_PARAMETER (3073) for them.

Parameters

oldMessageLimit

how many persisted messages to replay on subscribe: null for all of them (the default), 0 for none (live messages only), or N > 0 for the last N. Negative is rejected.

realtimeOverflow

the policy for live messages arriving faster than they drain.

maxQueue

how far a subscriber may fall behind under RealtimeOverflow.QUEUE before the server gives up on it and reports the range through PubSubMessageListener.onMessageDrop. It counts delivery batches, not messages. null (the default) leaves it to the server; N >= 1 asks for N, clamped to the server's maximum, and whichever subscriber subscribes to the topic first fixes it for everyone. Below 1, or combined with RealtimeOverflow.DROP, is rejected.

newMessageLimit

caps how many live messages this subscriber accepts per 500 ms server window, so roughly 2 × N a second. null (the default) or 0 means unlimited; negative is rejected. Messages past the cap are skipped for this subscriber only and reported through onMessageDrop once delivery continues, so capping a topic you also watch for drops produces drop callbacks by design.

Constructors

Link copied to clipboard
constructor(oldMessageLimit: Int? = null, realtimeOverflow: RealtimeOverflow = RealtimeOverflow.QUEUE, maxQueue: Int? = null, newMessageLimit: Int? = null)

Properties

Link copied to clipboard
val maxQueue: Int? = null
Link copied to clipboard
val newMessageLimit: Int? = null
Link copied to clipboard
val oldMessageLimit: Int? = null
Link copied to clipboard