Quick refactoring
This commit is contained in:
@@ -41,7 +41,6 @@ object Client: RelayPool.Listener {
|
|||||||
subscriptions = subscriptions + Pair(subscriptionId, filters)
|
subscriptions = subscriptions + Pair(subscriptionId, filters)
|
||||||
RelayPool.sendFilter(subscriptionId)
|
RelayPool.sendFilter(subscriptionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendFilterOnlyIfDisconnected(
|
fun sendFilterOnlyIfDisconnected(
|
||||||
subscriptionId: String = UUID.randomUUID().toString().substring(0..10),
|
subscriptionId: String = UUID.randomUUID().toString().substring(0..10),
|
||||||
filters: List<JsonFilter> = listOf(JsonFilter())
|
filters: List<JsonFilter> = listOf(JsonFilter())
|
||||||
|
|||||||
@@ -159,12 +159,7 @@ class Relay(
|
|||||||
|
|
||||||
fun sendFilter(requestId: String) {
|
fun sendFilter(requestId: String) {
|
||||||
if (read) {
|
if (read) {
|
||||||
if (socket == null) {
|
if (isConnected()) {
|
||||||
// waits 10 seconds
|
|
||||||
if (Date().time / 1000 > closingTime + 10) {
|
|
||||||
requestAndWatch()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isReady) {
|
if (isReady) {
|
||||||
val filters = Client.getSubscriptionFilters(requestId)
|
val filters = Client.getSubscriptionFilters(requestId)
|
||||||
if (filters.isNotEmpty()) {
|
if (filters.isNotEmpty()) {
|
||||||
@@ -174,6 +169,12 @@ class Relay(
|
|||||||
socket?.send(request)
|
socket?.send(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// waits 10 seconds to reconnect after disconnected.
|
||||||
|
if (Date().time / 1000 > closingTime + 10) {
|
||||||
|
// sends all filters after connection is successful.
|
||||||
|
requestAndWatch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user