From 3f907cdfc3d27ef8e553752395a00f776029dfff Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Thu, 17 Oct 2024 10:20:19 +0200 Subject: [PATCH] Update --- .../getstream/video/android/MainActivity.kt | 16 +--------- gradle/libs.versions.toml | 4 +-- .../video/android/core/IntegrationTestBase.kt | 2 +- .../video/android/core/StreamVideoBuilder.kt | 2 +- .../video/android/core/call/RtcSession.kt | 30 ++++++++++++++----- .../core/socket/common/StreamWebSocket.kt | 5 ++-- .../socket/common/parser2/MoshiVideoParser.kt | 4 +++ .../CoordinatorSocketConnection.kt | 9 +----- 8 files changed, 35 insertions(+), 37 deletions(-) diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/MainActivity.kt b/demo-app/src/main/kotlin/io/getstream/video/android/MainActivity.kt index 1fbae029af..49de2f3de4 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/MainActivity.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/MainActivity.kt @@ -69,21 +69,7 @@ class MainActivity : ComponentActivity() { val isLoggedIn = dataStore.user.firstOrNull() != null setContent { - VideoTheme( - colors = if (isSystemInDarkTheme()) { - // Dark - VideoTheme.colors.copy( - baseSheetPrimary = VideoTheme.colors.baseSheetPrimary, - baseSheetSecondary = VideoTheme.colors.baseSheetSecondary, - ) - } else { - // Light - VideoTheme.colors.copy( - baseSheetPrimary = VideoTheme.colors.baseSheetPrimary, - baseSheetSecondary = VideoTheme.colors.baseSheetSecondary, - ) - } - ) { + VideoTheme { AppNavHost( startDestination = if (!isLoggedIn) { AppScreens.Login.routeWithArg(true) // Pass true for autoLogIn diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 55b7ece9f3..d07b55c942 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -46,9 +46,9 @@ itu = "1.7.3" streamWebRTC = "1.2.1" streamNoiseCancellation = "1.0.1" -streamResult = "1.3.2" +streamResult = "1.3.0" streamChat = "6.5.1" -streamLog = "1.3.1" +streamLog = "1.1.4" streamPush = "1.1.8" androidxTest = "1.5.2" diff --git a/stream-video-android-core/src/androidTest/kotlin/io/getstream/video/android/core/IntegrationTestBase.kt b/stream-video-android-core/src/androidTest/kotlin/io/getstream/video/android/core/IntegrationTestBase.kt index 770aa2cb8a..866daff04c 100644 --- a/stream-video-android-core/src/androidTest/kotlin/io/getstream/video/android/core/IntegrationTestBase.kt +++ b/stream-video-android-core/src/androidTest/kotlin/io/getstream/video/android/core/IntegrationTestBase.kt @@ -19,9 +19,9 @@ package io.getstream.video.android.core import android.content.Context import androidx.test.core.app.ApplicationProvider import com.google.common.truth.Truth +import io.getstream.log.AndroidStreamLogger import io.getstream.log.Priority import io.getstream.log.StreamLog -import io.getstream.log.android.AndroidStreamLogger import io.getstream.log.streamLog import io.getstream.result.Result import io.getstream.video.android.core.logging.LoggingLevel diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt index fa1213cae9..1627b57c62 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt @@ -20,7 +20,7 @@ import android.app.Notification import android.content.Context import androidx.lifecycle.ProcessLifecycleOwner import com.jakewharton.threetenabp.AndroidThreeTen -import io.getstream.log.AndroidStreamLogger +import io.getstream.log.android.AndroidStreamLogger import io.getstream.log.StreamLog import io.getstream.log.streamLog import io.getstream.video.android.core.internal.module.CoordinatorConnectionModule diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt index f7f64f1739..fd79536c39 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt @@ -409,13 +409,13 @@ public class RtcSession internal constructor( userToken = sfuToken, lifecycle = coordinatorConnectionModule.lifecycle, ) - /*coordinatorConnectionModule.createSFUConnectionModule( - sfuUrl, - sessionId, - sfuToken, - getSdp, - onWebsocketReconnectStrategy, - )*/ + /*coordinatorConnectionModule.createSFUConnectionModule( + sfuUrl, + sessionId, + sfuToken, + getSdp, + onWebsocketReconnectStrategy, + )*/ setSfuConnectionModule(sfuConnectionModule) listenToSocketEventsAndErrors() @@ -453,7 +453,10 @@ public class RtcSession internal constructor( } errorJob = coroutineScope.launch { sfuConnectionModule.socketConnection.errors().collect { - logger.e(it.streamError.extractCause() ?: IllegalStateException("Error emitted without a cause on SFU connection.")) { "permanent failure on socket connection" } + logger.e( + it.streamError.extractCause() + ?: IllegalStateException("Error emitted without a cause on SFU connection.") + ) { "permanent failure on socket connection" } } } } @@ -495,6 +498,17 @@ public class RtcSession internal constructor( suspend fun connect() { sfuConnectionModule.socketConnection.connect(user = call.user) // ensure that the join event has been handled before starting RTC + sfuConnectionModule.socketConnection.whenConnected { + val request = JoinRequest( + session_id = sessionId, + token = sfuToken, + fast_reconnect = false, + client_details = clientDetails, + ) + sfuConnectionModule.socketConnection.sendEvent( + SfuDataRequest(SfuRequest(join_request = request)) + ) + } try { withTimeout(2000L) { joinEventReceivedMutex.withLock { connectRtc() } diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/StreamWebSocket.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/StreamWebSocket.kt index 2408cc98cb..07536f8c59 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/StreamWebSocket.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/StreamWebSocket.kt @@ -51,7 +51,7 @@ internal class StreamWebSocket>( }.onError { eventFlow.tryEmit(StreamWebSocketEvent.Error(it)) } - logger.v { "[handleEvent] event: `$event`" } + logger.v { "[handleEvent#ByteString] event: `$event`" } } override fun onMessage(webSocket: WebSocket, text: String) { @@ -60,7 +60,7 @@ internal class StreamWebSocket>( }.onError { eventFlow.tryEmit(StreamWebSocketEvent.Error(it)) } - logger.v { "[handleEvent] event: `$event`" } + logger.v { "[handleEvent#string] event: `$event`" } } override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) { @@ -89,6 +89,7 @@ internal class StreamWebSocket>( }) fun send(event: V): Boolean { + logger.d { "[send] event: `$event`" } val parsedEvent = parser.encode(event) return webSocket.send(parsedEvent) } diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/parser2/MoshiVideoParser.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/parser2/MoshiVideoParser.kt index 84c86f96e4..d24aef857d 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/parser2/MoshiVideoParser.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/common/parser2/MoshiVideoParser.kt @@ -16,11 +16,13 @@ package io.getstream.video.android.core.socket.common.parser2 +import com.squareup.moshi.FromJson import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonWriter import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi.Builder +import com.squareup.moshi.ToJson import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import io.getstream.video.android.core.socket.common.parser2.adapters.DateAdapter import io.getstream.video.android.core.socket.common.VideoParser @@ -151,11 +153,13 @@ internal class MoshiVideoParser : VideoParser { inline fun lenientAdapter(adapter: JsonAdapter): JsonAdapter { return object : JsonAdapter() { + @ToJson override fun toJson(writer: JsonWriter, value: T?) { writer.isLenient = true adapter.toJson(writer, value) } + @FromJson override fun fromJson(reader: JsonReader): T? { reader.isLenient = true return adapter.fromJson(reader) diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/coordinator/CoordinatorSocketConnection.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/coordinator/CoordinatorSocketConnection.kt index e834ff4348..34b5a270ee 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/coordinator/CoordinatorSocketConnection.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/coordinator/CoordinatorSocketConnection.kt @@ -126,7 +126,7 @@ public open class CoordinatorSocketConnection( super.onCreated() logger.d { "[onCreated] Socket is created" } scope.launch { - logger.d { "[onConnected] Video socket connected, user: $user" } + logger.d { "[onConnected] Video socket created, user: $user" } if (token.isEmpty()) { logger.e { "[onConnected] Token is empty. Disconnecting." } disconnect() @@ -180,13 +180,6 @@ public open class CoordinatorSocketConnection( override fun onDisconnected(cause: DisconnectCause) { super.onDisconnected(cause) logger.d { "[onDisconnected] Socket disconnected. Cause: $cause" } - when (cause) { - DisconnectCause.ConnectionReleased -> TODO() - is DisconnectCause.Error -> TODO() - DisconnectCause.NetworkNotAvailable -> TODO() - is DisconnectCause.UnrecoverableError -> TODO() - DisconnectCause.WebSocketNotAvailable -> TODO() - } } // API