Package 

Class StreamClientKt

    • Method Detail

      • StreamClient

         final static StreamClient StreamClient(CoroutineScope scope, Context context, StreamUser user, StreamTokenProvider tokenProvider, List<String> products, StreamSocketConfig socketConfig, StreamClientSerializationConfig serializationConfig, StreamHttpConfig httpConfig, StreamComponentProvider components)

        Creates a StreamClient with mandatory identity parameters and optional configuration.

        This is the primary entry point for product SDKs to create a client. All internal components are created with sensible defaults. Use components to replace specific internal components (for sharing instances or custom implementations).

        // Minimal — all defaults
        val client = StreamClient(
            scope = scope,
            context = context,
            user = user,
            tokenProvider = tokenProvider,
            products = listOf("chat"),
            socketConfig = StreamSocketConfig.jwt(
                url = StreamWsUrl.fromString("wss://chat.stream-io-api.com/connect"),
                apiKey = apiKey,
                clientInfoHeader = clientInfoHeader,
            ),
            serializationConfig = StreamClientSerializationConfig.default(chatEventSerializer),
        )
        
        // With tuned socket, custom logging, HTTP, and component overrides
        val singleFlight = StreamSingleFlightProcessor(scope)
        val client = StreamClient(
            scope = scope,
            context = context,
            user = user,
            tokenProvider = tokenProvider,
            products = listOf("feeds"),
            socketConfig = StreamSocketConfig.jwt(
                url = StreamWsUrl.fromString("wss://feeds.stream-io-api.com/connect"),
                apiKey = apiKey,
                clientInfoHeader = clientInfoHeader,
                healthCheckIntervalMs = 30_000,
            ),
            serializationConfig = StreamClientSerializationConfig.default(feedsEventSerializer),
            httpConfig = StreamHttpConfig(httpBuilder),
            components = StreamComponentProvider(
                logProvider = myLogProvider,
                singleFlight = singleFlight,
            ),
        )
        Parameters:
        scope - Coroutine scope powering internal work.
        context - Android application context.
        user - User identity.
        tokenProvider - Provides authentication tokens on demand.
        products - Stream product codes negotiated with the socket (e.g.
        socketConfig - WebSocket connection configuration (URL, auth, timing, batching).
        serializationConfig - JSON and event serialization configuration.
        httpConfig - Optional HTTP client customization (OkHttp builder, interceptors).
        components - Optional component overrides for DI.