PrivMX DOCS
C++

Stream Events

Stream events let your application react to Stream Room lifecycle changes and live media activity.

Types of Events

The Stream module exposes events such as:

  • streamRoomCreated
  • streamRoomUpdated
  • streamRoomDeleted
  • streamJoined
  • streamPublished
  • streamUpdated
  • streamUnpublished
  • streamLeft
  • remoteStreamsChanged
  • streamsUpdated

Handling Stream Events

Before receiving events, start an event loop and subscribe to the Stream events you need using buildSubscriptionQuery(...) and subscribeFor(...).

C++
// subscribing for Stream events
auto subscriptionIds = streamApi.subscribeFor({
    streamApi.buildSubscriptionQuery(stream::EventType::STREAMROOM_CREATE, stream::EventSelectorType::CONTEXT_ID, contextId),
    streamApi.buildSubscriptionQuery(stream::EventType::STREAM_PUBLISH, stream::EventSelectorType::STREAMROOM_ID, streamRoomId),
    streamApi.buildSubscriptionQuery(stream::EventType::STREAM_UNPUBLISH, stream::EventSelectorType::STREAMROOM_ID, streamRoomId),
});
std::cout << "STREAM_SUBSCRIPTIONS: " << subscriptionIds.size() << std::endl;

Use Context-level subscriptions for room lifecycle changes and Stream Room-level subscriptions for real-time activity inside a selected room.

C++
// unsubscribing from Stream events
streamApi.unsubscribeFrom(subscriptionIds);

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.

On this page

Stream Events | PrivMX Docs