Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions stream-video-android-core/api/stream-video-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -8886,7 +8886,6 @@ public final class io/getstream/video/android/core/ClientState {
public final fun getRingingCall ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getTelecomIntegrationType ()Lio/getstream/video/android/core/notifications/internal/telecom/TelecomIntegrationType;
public final fun getUser ()Lkotlinx/coroutines/flow/StateFlow;
public final fun handleError (Lio/getstream/result/Error;)V
public final fun handleEvent (Lio/getstream/android/video/generated/models/VideoEvent;)V
public final fun hasActiveOrRingingCall ()Z
public final fun removeActiveCall ()V
Expand All @@ -8895,49 +8894,6 @@ public final class io/getstream/video/android/core/ClientState {
public final fun setActiveCall (Lio/getstream/video/android/core/Call;)V
}

public abstract interface class io/getstream/video/android/core/ConnectionState {
}

public final class io/getstream/video/android/core/ConnectionState$Connected : io/getstream/video/android/core/ConnectionState {
public static final field INSTANCE Lio/getstream/video/android/core/ConnectionState$Connected;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/video/android/core/ConnectionState$Disconnected : io/getstream/video/android/core/ConnectionState {
public static final field INSTANCE Lio/getstream/video/android/core/ConnectionState$Disconnected;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/video/android/core/ConnectionState$Failed : io/getstream/video/android/core/ConnectionState {
public fun <init> (Lio/getstream/result/Error;)V
public final fun getError ()Lio/getstream/result/Error;
}

public final class io/getstream/video/android/core/ConnectionState$Loading : io/getstream/video/android/core/ConnectionState {
public static final field INSTANCE Lio/getstream/video/android/core/ConnectionState$Loading;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/video/android/core/ConnectionState$PreConnect : io/getstream/video/android/core/ConnectionState {
public static final field INSTANCE Lio/getstream/video/android/core/ConnectionState$PreConnect;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/video/android/core/ConnectionState$Reconnecting : io/getstream/video/android/core/ConnectionState {
public static final field INSTANCE Lio/getstream/video/android/core/ConnectionState$Reconnecting;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/video/android/core/CreateCallOptions {
public fun <init> ()V
public fun <init> (Ljava/util/List;Ljava/util/List;Ljava/util/Map;Lio/getstream/android/video/generated/models/CallSettingsRequest;Lorg/threeten/bp/OffsetDateTime;Ljava/lang/String;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package io.getstream.video.android.core
import app.cash.turbine.test
import app.cash.turbine.testIn
import com.google.common.truth.Truth.assertThat
import io.getstream.android.core.api.model.connection.StreamConnectionState
import io.getstream.android.video.generated.models.MemberRequest
import io.getstream.log.taggedLogger
import io.getstream.video.android.core.api.SignalServerService
Expand Down Expand Up @@ -260,7 +261,9 @@ class AndroidDeviceTest : IntegrationTestBase(connectCoordinatorWS = false) {

@Test
fun coordinatorWSConnection() = runTest {
assertThat(client.state.connection.value).isEqualTo(ConnectionState.Connected)
assertThat(
client.state.connection.value,
).isInstanceOf(StreamConnectionState.Connected::class.java)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,23 @@
package io.getstream.video.android.core

import androidx.compose.runtime.Stable
import io.getstream.android.core.api.model.connection.StreamConnectionState
import io.getstream.android.video.generated.models.CallCreatedEvent
import io.getstream.android.video.generated.models.CallRingEvent
import io.getstream.android.video.generated.models.ConnectedEvent
import io.getstream.android.video.generated.models.VideoEvent
import io.getstream.log.taggedLogger
import io.getstream.result.Error
import io.getstream.video.android.core.internal.InternalStreamVideoApi
import io.getstream.video.android.core.notifications.internal.service.CallService
import io.getstream.video.android.core.notifications.internal.service.ServiceIntentBuilder
import io.getstream.video.android.core.notifications.internal.service.ServiceLauncher
import io.getstream.video.android.core.notifications.internal.telecom.TelecomIntegrationType
import io.getstream.video.android.core.socket.coordinator.state.VideoSocketState
import io.getstream.video.android.core.utils.safeCallWithDefault
import io.getstream.video.android.model.User
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch

// These are UI states, need to move out.
@Stable
public sealed interface ConnectionState {
public data object PreConnect : ConnectionState
public data object Loading : ConnectionState
public data object Connected : ConnectionState
public data object Reconnecting : ConnectionState
public data object Disconnected : ConnectionState
public class Failed(val error: Error) : ConnectionState
}

// These are UI states, need to move out.
@Stable
public sealed interface RingingState {
Expand All @@ -64,8 +51,8 @@ class ClientState(private val client: StreamVideo) {

// Internal data
private val _user: MutableStateFlow<User?> = MutableStateFlow(client.user)
private val _connection: MutableStateFlow<ConnectionState> =
MutableStateFlow(ConnectionState.PreConnect)
private val _connection: MutableStateFlow<StreamConnectionState> =
MutableStateFlow(StreamConnectionState.Idle)
internal val _ringingCall: MutableStateFlow<Call?> = MutableStateFlow(null)
private val _activeCall: MutableStateFlow<Call?> = MutableStateFlow(null)

Expand All @@ -84,8 +71,11 @@ class ClientState(private val client: StreamVideo) {
_user.value = user
}

/** Coordinator connection state */
public val connection: StateFlow<ConnectionState> = _connection
/**
* Coordinator connection state. Surfaces core's [StreamConnectionState] directly —
* the same type the Feeds SDK exposes — so there is no video-local copy to maintain.
*/
public val connection: StateFlow<StreamConnectionState> = _connection

/** When there is an incoming call, this state will be set. */
public val ringingCall: StateFlow<Call?> = _ringingCall
Expand Down Expand Up @@ -127,12 +117,7 @@ class ClientState(private val client: StreamVideo) {
* Most event logic happens in the Call instead of the client
*/
fun handleEvent(event: VideoEvent) {
// mark connected
when (event) {
is ConnectedEvent -> {
_connection.value = ConnectionState.Connected
}

is CallCreatedEvent -> {
// what's the right thing to do here?
// if it's ringing we add it
Expand All @@ -150,28 +135,9 @@ class ClientState(private val client: StreamVideo) {
}
}

internal fun handleState(socketState: VideoSocketState) {
val state = when (socketState) {
// Before connection is established
is VideoSocketState.Disconnected.Stopped -> ConnectionState.PreConnect
// Loading
is VideoSocketState.Connecting -> ConnectionState.Loading
// Connected
is VideoSocketState.Connected -> ConnectionState.Connected
// Reconnecting
is VideoSocketState.Disconnected.DisconnectedTemporarily -> ConnectionState.Reconnecting
is VideoSocketState.RestartConnection -> ConnectionState.Reconnecting
// Disconnected
is VideoSocketState.Disconnected.WebSocketEventLost -> ConnectionState.Disconnected
is VideoSocketState.Disconnected.NetworkDisconnected -> ConnectionState.Disconnected
is VideoSocketState.Disconnected.DisconnectedByRequest -> ConnectionState.Disconnected
is VideoSocketState.Disconnected.DisconnectedPermanently -> ConnectionState.Disconnected
}
_connection.value = state
}

fun handleError(error: Error) {
_connection.value = ConnectionState.Failed(error)
/** Routes the coordinator connection state reported by core's StreamClient listener. */
internal fun handleStreamState(streamState: StreamConnectionState) {
_connection.value = streamState
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ internal class StreamVideoClient internal constructor(
}

override fun onState(state: StreamConnectionState) {
// TODO: replace with this@StreamVideoClient.state.handleStreamState(state) once
// ClientState.handleStreamState lands in the follow-up ConnectionState PR. Held to
// validate the listener wiring at SDK init; connection-state routing comes with it.
this@StreamVideoClient.state.handleStreamState(state)
Comment thread
rahul-lohra marked this conversation as resolved.
}

override fun onError(err: Throwable) {
Expand Down Expand Up @@ -425,7 +423,7 @@ internal class StreamVideoClient internal constructor(
init {
// Subscribe once to the StreamClient's listener stream. Events cast to VideoEvent
// are forwarded to the existing fireEvent(...) dispatch pipeline; connection state
// routing arrives with the ConnectionState rewrite (see streamClientListener.onState).
// routes through ClientState.handleStreamState (see streamClientListener.onState).
streamClientSubscription = streamClient.subscribe(streamClientListener).getOrThrow()

// Re-watch active calls whenever the coordinator socket (re)connects.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.getstream.video.android.core

import com.google.common.truth.Truth.assertThat
import io.getstream.android.core.api.model.connection.StreamConnectionState
import io.getstream.android.video.generated.models.ConnectedEvent
import io.getstream.android.video.generated.models.VideoEvent
import io.getstream.log.taggedLogger
Expand Down Expand Up @@ -235,14 +236,16 @@ class ClientAndAuthTest : TestBase() {
user = testData.users["thierry"]!!,
token = authData!!.token,
).build()
assertThat(client.state.connection.value).isEqualTo(ConnectionState.PreConnect)
assertThat(client.state.connection.value).isEqualTo(StreamConnectionState.Idle)
val clientImpl = client as StreamVideoClient

val connectResultDeferred = clientImpl.connectAsync()

val connectResult = connectResultDeferred.await()
delay(100L)
assertThat(client.state.connection.value).isEqualTo(ConnectionState.Connected)
assertThat(
client.state.connection.value,
).isInstanceOf(StreamConnectionState.Connected::class.java)
}

@Test
Expand Down

This file was deleted.

Loading
Loading