mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-07-14 02:47:19 +02:00
Fixes some connectivity issues by basing the timeout from the last connection tentative instead of the drop out time.
This commit is contained in:
@ -77,7 +77,7 @@ class Relay(
|
|||||||
var errorCounter = 0
|
var errorCounter = 0
|
||||||
var pingInMs: Long? = null
|
var pingInMs: Long? = null
|
||||||
|
|
||||||
var closingTimeInSeconds = 0L
|
var lastConnectTentative: Long = 0L
|
||||||
|
|
||||||
var afterEOSEPerSubscription = mutableMapOf<String, Boolean>()
|
var afterEOSEPerSubscription = mutableMapOf<String, Boolean>()
|
||||||
|
|
||||||
@ -120,6 +120,8 @@ class Relay(
|
|||||||
|
|
||||||
if (socket != null) return
|
if (socket != null) return
|
||||||
|
|
||||||
|
lastConnectTentative = TimeUtils.now()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val request =
|
val request =
|
||||||
Request.Builder()
|
Request.Builder()
|
||||||
@ -251,7 +253,6 @@ class Relay(
|
|||||||
this.isReady = false
|
this.isReady = false
|
||||||
this.usingCompression = false
|
this.usingCompression = false
|
||||||
this.resetEOSEStatuses()
|
this.resetEOSEStatuses()
|
||||||
this.closingTimeInSeconds = TimeUtils.now()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun processNewRelayMessage(newMessage: String) {
|
fun processNewRelayMessage(newMessage: String) {
|
||||||
@ -331,7 +332,7 @@ class Relay(
|
|||||||
Log.d("Relay", "Relay.disconnect $url")
|
Log.d("Relay", "Relay.disconnect $url")
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
|
|
||||||
closingTimeInSeconds = TimeUtils.now()
|
lastConnectTentative = 0L // this is not an error, so prepare to reconnect as soon as requested.
|
||||||
socket?.cancel()
|
socket?.cancel()
|
||||||
socket = null
|
socket = null
|
||||||
isReady = false
|
isReady = false
|
||||||
@ -373,7 +374,7 @@ class Relay(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// waits 60 seconds to reconnect after disconnected.
|
// waits 60 seconds to reconnect after disconnected.
|
||||||
if (TimeUtils.now() > closingTimeInSeconds + RECONNECTING_IN_SECONDS) {
|
if (TimeUtils.now() > lastConnectTentative + RECONNECTING_IN_SECONDS) {
|
||||||
// sends all filters after connection is successful.
|
// sends all filters after connection is successful.
|
||||||
connect()
|
connect()
|
||||||
}
|
}
|
||||||
@ -413,7 +414,7 @@ class Relay(
|
|||||||
|
|
||||||
if (socket == null) {
|
if (socket == null) {
|
||||||
// waits 60 seconds to reconnect after disconnected.
|
// waits 60 seconds to reconnect after disconnected.
|
||||||
if (TimeUtils.now() > closingTimeInSeconds + RECONNECTING_IN_SECONDS) {
|
if (TimeUtils.now() > lastConnectTentative + RECONNECTING_IN_SECONDS) {
|
||||||
// println("sendfilter Only if Disconnected ${url} ")
|
// println("sendfilter Only if Disconnected ${url} ")
|
||||||
connect()
|
connect()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user