正在显示
3 个修改的文件
包含
26 行增加
和
5 行删除
| @@ -18,7 +18,11 @@ package io.livekit.android.events | @@ -18,7 +18,11 @@ package io.livekit.android.events | ||
| 18 | 18 | ||
| 19 | import io.livekit.android.e2ee.E2EEState | 19 | import io.livekit.android.e2ee.E2EEState |
| 20 | import io.livekit.android.room.Room | 20 | import io.livekit.android.room.Room |
| 21 | -import io.livekit.android.room.participant.* | 21 | +import io.livekit.android.room.participant.ConnectionQuality |
| 22 | +import io.livekit.android.room.participant.LocalParticipant | ||
| 23 | +import io.livekit.android.room.participant.Participant | ||
| 24 | +import io.livekit.android.room.participant.ParticipantPermission | ||
| 25 | +import io.livekit.android.room.participant.RemoteParticipant | ||
| 22 | import io.livekit.android.room.track.LocalTrackPublication | 26 | import io.livekit.android.room.track.LocalTrackPublication |
| 23 | import io.livekit.android.room.track.RemoteTrackPublication | 27 | import io.livekit.android.room.track.RemoteTrackPublication |
| 24 | import io.livekit.android.room.track.Track | 28 | import io.livekit.android.room.track.Track |
| @@ -26,6 +30,12 @@ import io.livekit.android.room.track.TrackPublication | @@ -26,6 +30,12 @@ import io.livekit.android.room.track.TrackPublication | ||
| 26 | import livekit.LivekitModels | 30 | import livekit.LivekitModels |
| 27 | 31 | ||
| 28 | sealed class RoomEvent(val room: Room) : Event() { | 32 | sealed class RoomEvent(val room: Room) : Event() { |
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Connected to Room | ||
| 36 | + */ | ||
| 37 | + class Connected(room: Room) : RoomEvent(room) | ||
| 38 | + | ||
| 29 | /** | 39 | /** |
| 30 | * A network change has been detected and LiveKit attempts to reconnect to the room | 40 | * A network change has been detected and LiveKit attempts to reconnect to the room |
| 31 | * When reconnect attempts succeed, the room state will be kept, including tracks that are subscribed/published | 41 | * When reconnect attempts succeed, the room state will be kept, including tracks that are subscribed/published |
| @@ -279,7 +279,6 @@ constructor( | @@ -279,7 +279,6 @@ constructor( | ||
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | engine.join(url, token, options, roomOptions) | 281 | engine.join(url, token, options, roomOptions) |
| 282 | - | ||
| 283 | val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | 282 | val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager |
| 284 | val networkRequest = NetworkRequest.Builder() | 283 | val networkRequest = NetworkRequest.Builder() |
| 285 | .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) | 284 | .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) |
| @@ -669,6 +668,7 @@ constructor( | @@ -669,6 +668,7 @@ constructor( | ||
| 669 | */ | 668 | */ |
| 670 | override fun onEngineConnected() { | 669 | override fun onEngineConnected() { |
| 671 | state = State.CONNECTED | 670 | state = State.CONNECTED |
| 671 | + eventBus.postEvent(RoomEvent.Connected(this), coroutineScope) | ||
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | /** | 674 | /** |
| @@ -60,11 +60,17 @@ class RoomMockE2ETest : MockE2ETest() { | @@ -60,11 +60,17 @@ class RoomMockE2ETest : MockE2ETest() { | ||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | @Test | 62 | @Test |
| 63 | - fun connectNoEvents() = runTest { | 63 | + fun connectEvent() = runTest { |
| 64 | val collector = EventCollector(room.events, coroutineRule.scope) | 64 | val collector = EventCollector(room.events, coroutineRule.scope) |
| 65 | connect() | 65 | connect() |
| 66 | val events = collector.stopCollecting() | 66 | val events = collector.stopCollecting() |
| 67 | - assertEquals(emptyList<RoomEvent>(), events) | 67 | + |
| 68 | + assertIsClassList( | ||
| 69 | + listOf( | ||
| 70 | + RoomEvent.Connected::class.java, | ||
| 71 | + ), | ||
| 72 | + events, | ||
| 73 | + ) | ||
| 68 | } | 74 | } |
| 69 | 75 | ||
| 70 | @Test | 76 | @Test |
| @@ -80,7 +86,12 @@ class RoomMockE2ETest : MockE2ETest() { | @@ -80,7 +86,12 @@ class RoomMockE2ETest : MockE2ETest() { | ||
| 80 | val collector = EventCollector(room.events, coroutineRule.scope) | 86 | val collector = EventCollector(room.events, coroutineRule.scope) |
| 81 | connect(joinResponse) | 87 | connect(joinResponse) |
| 82 | val events = collector.stopCollecting() | 88 | val events = collector.stopCollecting() |
| 83 | - assertEquals(emptyList<RoomEvent>(), events) | 89 | + assertIsClassList( |
| 90 | + listOf( | ||
| 91 | + RoomEvent.Connected::class.java, | ||
| 92 | + ), | ||
| 93 | + events, | ||
| 94 | + ) | ||
| 84 | } | 95 | } |
| 85 | 96 | ||
| 86 | @Test | 97 | @Test |
-
请 注册 或 登录 后发表评论