org.java_websocket.client.WebSocketClient It does not show any reaction when the internet is interrupted by mobile data

private var webSocketClient: WebSocketClient? = null

private fun createWebSocketClient() {
    val uri: URI
    try {
        uri = URI(BuildConfig.SOCKET_URL)
    } catch (e: URISyntaxException) {
        e.printStackTrace()
        return
    }
    webSocketClient = object : WebSocketClient(uri) {
        override fun onOpen(handshakedata: ServerHandshake?) {
        }

        override fun onMessage(message: String) {
        }

        override fun onClose(code: Int, reason: String?, remote: Boolean) {
        }

        override fun onError(ex: java.lang.Exception?) {
        }
    }
    webSocketClient!!.connectionLostTimeout = 10000
    webSocketClient!!.connect()
}

Please give me a solution to let me know in the app when the internet is interrupted by mobile data.

0

There are 0 best solutions below