Merge pull request #959 from greenart7c3/main

add onerror when websocket is null
This commit is contained in:
Vitor Pamplona
2024-06-30 09:58:40 -04:00
committed by GitHub

View File

@@ -524,9 +524,17 @@ class Relay(
}
private fun writeToSocket(str: String) {
if (socket == null) {
listeners.forEach { listener ->
listener.onError(
this@Relay,
"",
Error("Failed to send $str. Relay is not connected."),
)
}
}
socket?.let {
checkNotInMainThread()
val result = it.send(str)
listeners.forEach { listener ->
listener.onSend(this@Relay, str, result)