Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandar-apostolov committed Mar 19, 2024
2 parents 66b931b + 82a1073 commit 9b1dcc5
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import org.webrtc.VideoSink
import org.webrtc.audio.JavaAudioDeviceModule.AudioSamples
import stream.video.sfu.models.TrackType
import stream.video.sfu.models.VideoDimension
import java.util.Collections
import kotlin.coroutines.resume

/**
Expand All @@ -113,7 +114,7 @@ public class Call(
val user: User,
) {
private var location: String? = null
private var subscriptions = mutableSetOf<EventSubscription>()
private var subscriptions = Collections.synchronizedSet(mutableSetOf<EventSubscription>())

internal val clientImpl = client as StreamVideoImpl

Expand Down Expand Up @@ -822,7 +823,7 @@ public class Call(
public fun subscribeFor(
vararg eventTypes: Class<out VideoEvent>,
listener: VideoEventListener<VideoEvent>,
): EventSubscription {
): EventSubscription = synchronized(subscriptions) {
val filter = { event: VideoEvent ->
eventTypes.any { type -> type.isInstance(event) }
}
Expand All @@ -833,7 +834,7 @@ public class Call(

public fun subscribe(
listener: VideoEventListener<VideoEvent>,
): EventSubscription {
): EventSubscription = synchronized(subscriptions) {
val sub = EventSubscription(listener)
subscriptions.add(sub)
return sub
Expand Down Expand Up @@ -877,7 +878,7 @@ public class Call(
return clientImpl.updateMembers(type, id, request)
}

fun fireEvent(event: VideoEvent) {
fun fireEvent(event: VideoEvent) = synchronized(subscriptions) {
subscriptions.forEach { sub ->
if (!sub.isDisposed) {
// subs without filters should always fire
Expand Down

0 comments on commit 9b1dcc5

Please sign in to comment.