mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-29 19:43:23 +02:00
add onerror when websocket is null
This commit is contained in:
@@ -524,9 +524,17 @@ class Relay(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun writeToSocket(str: String) {
|
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 {
|
socket?.let {
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
|
|
||||||
val result = it.send(str)
|
val result = it.send(str)
|
||||||
listeners.forEach { listener ->
|
listeners.forEach { listener ->
|
||||||
listener.onSend(this@Relay, str, result)
|
listener.onSend(this@Relay, str, result)
|
||||||
|
Reference in New Issue
Block a user