Skip to main content

Events

In most cases, you should rely on the StreamVideo or CallViewModel and its events for building and updating your UI. However for some customizations you'll want to listen to the underlying events that power these objects.

Listening to events

Both the call and streamVideo object allow you to subscribe to events. You can listen to a specific event or all of them. This example shows how to listen to all events.

Task {
for await event in streamVideo.subscribe() {
print(event)
}
}

You can also subscribe for a specific call.

Task {
let call = streamVideo.call("default", "123")
for await event in call.subscribe() {
print(event)
}
}
note

When subscribing to all events either on the client or a call, you will be receiving events of type VideoEvent. VideoEvent is the discriminator object for all websocket events, you should use this to map event payloads to their own type.

Task {
let call = streamVideo.call("default", "123")
for await event in call.subscribe() {
switch event {
case .typeBlockedUserEvent(let blockedUserEvent):
print(blockedUserEvent)
case .typeCallAcceptedEvent(let callAcceptedEvent):
print(callAcceptedEvent)
default:
break
}
}
}

Or listen to a specific event

Task {
let call = streamVideo.call("default", "123")
for await event in call.subscribe(for: ConnectedEvent.self) {
print(event)
}
}

Events

The following events are triggered by the client:

Event NameDescription
BlockedUserEventThis event is sent to call participants to notify when a user is blocked on a call, clients can use this event to show a notification. If the user is the current user, the client should leave the call screen as well
CallAcceptedEventThis event is sent when a user accepts a notification to join a call.
CallBroadcastingStartedEventThis event is sent when call broadcasting has started
CallBroadcastingStoppedEventThis event is sent when call broadcasting has stopped
CallCreatedEventThis event is sent when a call is created. Clients receiving this event should check if the ringing field is set to true and if so, show the call screen
CallEndedEventThis event is sent when a call is mark as ended for all its participants. Clients receiving this event should leave the call screen
CallLiveStartedEventThis event is sent when a call is started. Clients receiving this event should start the call.
CallMemberAddedEventThis event is sent when one or more members are added to a call
CallMemberRemovedEventThis event is sent when one or more members are removed from a call
CallMemberUpdatedEventThis event is sent when one or more members are updated
CallMemberUpdatedPermissionEventThis event is sent when one or more members get its role updated
CallNotificationEventThis event is sent to all call members to notify they are getting called
CallReactionEventThis event is sent when a reaction is sent in a call, clients should use this to show the reaction in the call screen
CallRecordingStartedEventThis event is sent when call recording has started
CallRecordingStoppedEventThis event is sent when call recording has stopped
CallRejectedEventThis event is sent when a user rejects a notification to join a call.
CallRingEventThis event is sent to all call members to notify they are getting called
CallSessionEndedEventThis event is sent when a call session ends
CallSessionParticipantJoinedEventThis event is sent when a participant joins a call session
CallSessionParticipantLeftEventThis event is sent when a participant leaves a call session
CallSessionStartedEventThis event is sent when a call session starts
CallUpdatedEventThis event is sent when a call is updated, clients should use this update the local state of the call. This event also contains the capabilities by role for the call, clients should update the own_capability for the current.
ConnectedEventThis event is sent when the WS connection is established and authenticated, this event contains the full user object as it is stored on the server
ConnectionErrorEventThis event is sent when the WS connection fails
CustomVideoEventA custom event, this event is used to send custom events to other participants in the call.
HealthCheckEvent-
PermissionRequestEventThis event is sent when a user requests access to a feature on a call, clients receiving this event should display a permission request to the user
UnblockedUserEventThis event is sent when a user is unblocked on a call, this can be useful to notify the user that they can now join the call again
UpdatedCallPermissionsEventThis event is sent to notify about permission changes for a user, clients receiving this event should update their UI accordingly
VideoEventThe discriminator object for all websocket events, you should use this to map event payloads to their own type
WSCallEventThis is just a placeholder for all call events
WSClientEventThis is just a placeholder for all client events

Did you find this page helpful?