# Wrapped the WebSocket with Kotlin Channels and Flow

**URL:** <https://discuss.kotlinlang.org/t/wrapped-the-websocket-with-kotlin-channels-and-flow/19450>\
**Category:** Android\
**Created:** [October 11, 2020, 1:12pm UTC](https://discuss.kotlinlang.org/t/wrapped-the-websocket-with-kotlin-channels-and-flow/19450 "2020-10-11T13:12:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim4dev](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@tim4dev](https://discuss.kotlinlang.org/u/tim4dev)\
**Post date:** [October 11, 2020, 1:12pm UTC](https://discuss.kotlinlang.org/t/wrapped-the-websocket-with-kotlin-channels-and-flow/19450/1 "2020-10-11T13:12:19Z")

</div>

Hello colleagues!  
I tried [wrapping the WebSocket with Kotlin Channels and Flow](https://bitbucket.org/tim4dev/workspace/snippets/jLGAzd).  
Perhaps you could do it more elegantly.  
I look forward to your comments.

---

<div class="post-metadata">

**Author:** ![lamba92](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lamba92/32/5089_2.png) [@lamba92](https://discuss.kotlinlang.org/u/lamba92)\
**Post date:** [October 11, 2020, 1:45pm UTC](https://discuss.kotlinlang.org/t/wrapped-the-websocket-with-kotlin-channels-and-flow/19450/2 "2020-10-11T13:45:44Z")

</div>

Consider wrapping your `OkHttpClient` with [Ktor Client](https://ktor.io/docs/http-client-engines.html?_ga=2.105123969.381728508.1602371153-699513710.1593771485&_gac=1.116374772.1599074912.Cj0KCQjwhb36BRCfARIsAKcXh6F-DoeOYHHpgzOSVDE8Ej4nVkGq95zIR2zANGvedDlfIrM17KLlNEMaAjd2EALw_wcB#okhttp) and use the WebSocket [feature](https://ktor.io/docs/clients-websockets.html)!
