Ayomide

    Ayomide

    1 year ago
    Hey, I'm trying out Ktor's WebSocket client library. It returns incoming messages from a web socket as a
    SharedFlow
    - I'm trying to figure out how to keep the web socket session (
    DefaultClientWebSocketSession
    ) running in the background so that I can collect the
    SharedFlow
    messages and display them on screen as they stream in into a
    LazyColumn
    or similar. I'm not sure how to fit this into Compose's state tools. I tried using
    coroutineScope.launch{}
    with
    rememberCoroutineScope()
    but it seems like the web socket session would stop as soon as the coroutine scope ended.
    ahulyk

    ahulyk

    1 year ago
    you need 'wider' scope - for testing try Global scope
    Ayomide

    Ayomide

    1 year ago
    Hmm, trying that still results in the session immediately closing