Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandar-apostolov committed Oct 17, 2024
1 parent 9ad0baf commit 3f907cd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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" }
}
}
}
Expand Down Expand Up @@ -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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal class StreamWebSocket<V, T: GenericParser<V>>(
}.onError {
eventFlow.tryEmit(StreamWebSocketEvent.Error(it))
}
logger.v { "[handleEvent] event: `$event`" }
logger.v { "[handleEvent#ByteString] event: `$event`" }
}

override fun onMessage(webSocket: WebSocket, text: String) {
Expand All @@ -60,7 +60,7 @@ internal class StreamWebSocket<V, T: GenericParser<V>>(
}.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?) {
Expand Down Expand Up @@ -89,6 +89,7 @@ internal class StreamWebSocket<V, T: GenericParser<V>>(
})

fun send(event: V): Boolean {
logger.d { "[send] event: `$event`" }
val parsedEvent = parser.encode(event)
return webSocket.send(parsedEvent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -151,11 +153,13 @@ internal class MoshiVideoParser : VideoParser {
inline fun <reified T> lenientAdapter(adapter: JsonAdapter<T>): JsonAdapter<T> {
return object : JsonAdapter<T>() {

@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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3f907cd

Please sign in to comment.