subscribe
Subscribes to a topic; the listener receives every message published on it.
Persisted (old) messages of the topic are replayed right after subscribing, in server-paced batches, via onOldMessagesReceived — whose default forwards each batch to onOldMessagesReceived. The final batch carries isLast() == true; a topic with no history fires no history callback at all.
Requires a joined meeting. Called before the join completes — before onMeetingJoined fires, even if the connection is already up — it throws and onError fires with code 3001 (ERROR_ACTION_PERFORMED_BEFORE_MEETING_JOINED), whose message names this method. While the meeting is RECONNECTING it throws and onError fires with code 3014 (ERROR_MEETING_RECONNECTING); the call is not replayed for you once the meeting reconnects.
If the server rejects the subscription, the listener is unregistered again and onError fires with code 4088 (PUBSUB_SUBSCRIBE_FAILED) carrying the server's reason. Subscribing while the pubsub connection is down and has not yet been re-established throws and fires code 3013 (OPERATION_TIMEOUT); the listener is not registered.
Code Example:
try {
meeting.pubSub.subscribe("CHAT", pubSubMessageListener);
} catch (Exception e) {
Log.d("VideoSDK", "subscribe failed: " + e.getMessage());
}
Parameters
the topic name to subscribe to
the PubSubMessageListener to receive messages on this topic
Throws
if this listener instance is already subscribed to this topic; register a second listener instead, or unsubscribe first
if the meeting is not joined or is reconnecting, or the pubsub connection is temporarily down; the subscription is not registered — retry after the meeting has joined or finished reconnecting
Subscribes to a topic, bounding how much history is replayed and how live messages are paced.
History is delivered exactly as it is without options — in server-paced batches via onOldMessagesReceived, the final batch carrying isLast == true, and no callback at all on a topic with no history. What the options change is how much history is replayed (setOldMessageLimit).
Overflow of live messages under load is controlled by PubSubSubscribeOptions.RealtimeOverflow, with drops reported via onMessageDrop.
Requires a joined meeting. Called before the join completes — before onMeetingJoined fires, even if the connection is already up — it throws and onError fires with code 3001 (ERROR_ACTION_PERFORMED_BEFORE_MEETING_JOINED), whose message names this method. While the meeting is RECONNECTING it throws and onError fires with code 3014 (ERROR_MEETING_RECONNECTING); the call is not replayed for you once the meeting reconnects.
If the server rejects the subscription, the listener is unregistered again and onError fires with code 4088 (PUBSUB_SUBSCRIBE_FAILED) carrying the server's reason. Subscribing while the pubsub connection is down and has not yet been re-established throws and fires code 3013 (OPERATION_TIMEOUT); the listener is not registered.
Code Example:
try {
PubSubSubscribeOptions options = new PubSubSubscribeOptions();
options.setOldMessageLimit(100);
meeting.pubSub.subscribe("CHAT", listener, options);
} catch (Exception e) {
Log.d("VideoSDK", "subscribe failed: " + e.getMessage());
}
Parameters
the topic name to subscribe to
the PubSubMessageListener to receive messages on this topic
the PubSubSubscribeOptions controlling history, pacing and overflow; null behaves exactly like subscribe
Throws
if the options are invalid (e.g. negative oldMessageLimit, or maxQueue combined with RealtimeOverflow.DROP), or if this listener instance is already subscribed to this topic
if the meeting is not joined or is reconnecting, or the pubsub connection is temporarily down; the subscription is not registered — retry after the meeting has joined or finished reconnecting