Chirag Asarpota
Chirag Asarpota

Reputation: 131

Websocket client in Kotlin

I was wondering why there is no Websocket client native object in Kotlin like it is in javascript.

How does one connect to a Websocket server in kotlin as I created a Node.js websocket server and want to connect to it using an Android client.

Can someone please elaborate on this.

Thanks.

Upvotes: 6

Views: 13646

Answers (1)

Dmitri
Dmitri

Reputation: 2972

There is. If your question is about Kotlin native/multiplatform, you can use ktor client: https://ktor.io/clients/websockets.html.

On the Android side, you would need to use CIO or OKHttp engines. On the javascript side, Js engine. On the iOS side, there is currently no support available out of the box, but it's supposed to be coming soon.

If your question is not about Kotlin native/multiplaform, you can still use the above or org.java_websocket.client.WebSocketClient, or any of the third party libs.

Upvotes: 2

Related Questions