-
- All Implemented Interfaces:
-
io.getstream.android.core.api.subscribe.StreamObservable
public interface StreamClient implements StreamObservable<StreamClientListener>
Entry point for establishing and managing a connection to Stream services.
Exposes connection-related state via connectionState (hot, read-only).
Implementations may perform network I/O and authentication during connect.
All APIs are safe to call from any thread.
connect and disconnect are
suspendand must not block the caller thread.
Create → connect → use → disconnect.
After disconnect, resources are released; connectionState continues to reflect the latest status.
Methods return
Result<…>:successon completion,failureon error.If the caller is cancelled while awaiting, a kotlinx.coroutines.CancellationException is thrown.
// Use val result = client.connect() if (result.isSuccess) { // Observe connection state // Connected... } else { val cause = result.exceptionOrNull() // handle error } // Observe exposed client state client.state.collect { // Get state updates... } // … client.disconnect()
-
-
Method Summary
Modifier and Type Method Description abstract Result<StreamConnectedUser>connect()Establishes a connection for the current user. abstract Result<Unit>disconnect()Terminates the active connection and releases related resources. abstract StateFlow<StreamConnectionState>getConnectionState()Read-only, hot state holder for this client. -
-
Method Detail
-
connect
abstract Result<StreamConnectedUser> connect()
Establishes a connection for the current user.
Result contract
Result.success(StreamConnectedUser)on success.Result.failure(cause)if the connection fails.
Cancellation
Throws kotlinx.coroutines.CancellationException if the awaiting coroutine is cancelled.
-
disconnect
abstract Result<Unit> disconnect()
Terminates the active connection and releases related resources.
Result contract
Result.success(Unit)on a clean shutdown.Result.failure(cause)if teardown fails.
Cancellation
Throws kotlinx.coroutines.CancellationException if the awaiting coroutine is cancelled.
-
getConnectionState
abstract StateFlow<StreamConnectionState> getConnectionState()
Read-only, hot state holder for this client.
Semantics
Emits connection status changes (e.g., connecting/connected/disconnected).
Hot & conflated: new collectors receive the latest value immediately.
-
-
-
-