mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-22 02:30:31 +02:00
Marking relays with failure as not connected
This commit is contained in:
@@ -30,6 +30,7 @@ class Relay(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun requestAndWatch() {
|
fun requestAndWatch() {
|
||||||
|
println("Connecting with ${url}")
|
||||||
val request = Request.Builder().url(url).build()
|
val request = Request.Builder().url(url).build()
|
||||||
val listener = object : WebSocketListener() {
|
val listener = object : WebSocketListener() {
|
||||||
|
|
||||||
@@ -87,6 +88,9 @@ class Relay(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
|
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
|
||||||
|
// Failures disconnect the relay.
|
||||||
|
socket = null
|
||||||
|
//println("Relay onFailure ${url}, ${response?.message}")
|
||||||
t.printStackTrace()
|
t.printStackTrace()
|
||||||
listeners.forEach {
|
listeners.forEach {
|
||||||
it.onError(this@Relay, "", Error("WebSocket Failure. Response: ${response}. Exception: ${t.message}", t))
|
it.onError(this@Relay, "", Error("WebSocket Failure. Response: ${response}. Exception: ${t.message}", t))
|
||||||
@@ -99,6 +103,7 @@ class Relay(
|
|||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
//httpClient.dispatcher.executorService.shutdown()
|
//httpClient.dispatcher.executorService.shutdown()
|
||||||
socket?.close(1000, "Normal close")
|
socket?.close(1000, "Normal close")
|
||||||
|
socket = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendFilter(requestId: String) {
|
fun sendFilter(requestId: String) {
|
||||||
|
Reference in New Issue
Block a user