Package 

Interface StreamClient

  • 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 suspend and 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<…>: success on completion, failure on 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.
      • Methods inherited from class io.getstream.android.core.api.StreamClient

        subscribe
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.