Stream Events
Listen for Stream Room and live stream events.
Listening for Stream events lets your app react to room lifecycle changes and real-time media activity.
Types of Events
The Stream module exposes the following event groups:
streamRoomCreated- triggers when a new Stream Room is createdstreamRoomUpdated- triggers when a Stream Room is updatedstreamRoomDeleted- triggers when a Stream Room is deletedstreamJoined- triggers when a user joins and publishes stream identifiers in a roomstreamPublished- triggers when a stream is publishedstreamUpdated- triggers when a published stream changesstreamUnpublished- triggers when a stream is unpublishedstreamLeft- triggers when a stream leaves the roomremoteStreamsChanged- triggers when the set of remote streams available for subscription changesstreamsUpdated- triggers when subscribed stream information changes
Handling Stream Events
Sample code on this page is based on the initial assumptions.
Before receiving events, your application has to start an event loop and subscribe to specific events in the required scope.
Use buildSubscriptionQuery(...) together with subscribeFor(...) to register subscriptions.
Choosing a Scope
StreamApi.buildSubscriptionQuery(...) uses:
EventType- the type of Stream event to listen forEventSelectorType- the scope of the subscription- selector ID - the concrete Context, Stream Room, or Stream ID
Typical scopes are:
CONTEXT_ID- listen for room creation or updates in a whole ContextSTREAMROOM_ID- listen for publish, update, and room-specific activitySTREAM_ID- listen for changes related to a particular stream
Recommended Usage
In most apps, a good setup is:
- subscribe at Context level for room lifecycle events
- subscribe at Stream Room level when a user enters a live room
- update the UI after
remoteStreamsChangedandstreamsUpdated - clean up subscriptions when leaving the room
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.
Working with Streams
Use StreamApi to manage Stream Rooms and real-time media streams.
Events
Events allow your application to dynamically respond to changes in user context instantly. These events are automatically captured when relevant changes occur. You can subscribe to them by registering event listeners.