mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 18:51:12 +02:00
Marks which relays are using compression
This commit is contained in:
@@ -47,6 +47,7 @@ class Relay(
|
|||||||
private var listeners = setOf<Listener>()
|
private var listeners = setOf<Listener>()
|
||||||
private var socket: WebSocket? = null
|
private var socket: WebSocket? = null
|
||||||
private var isReady: Boolean = false
|
private var isReady: Boolean = false
|
||||||
|
private var usingCompression: Boolean = false
|
||||||
|
|
||||||
var eventDownloadCounterInBytes = 0
|
var eventDownloadCounterInBytes = 0
|
||||||
var eventUploadCounterInBytes = 0
|
var eventUploadCounterInBytes = 0
|
||||||
@@ -118,7 +119,10 @@ class Relay(
|
|||||||
override fun onOpen(webSocket: WebSocket, response: Response) {
|
override fun onOpen(webSocket: WebSocket, response: Response) {
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
|
|
||||||
markConnectionAsReady(response.receivedResponseAtMillis - response.sentRequestAtMillis)
|
markConnectionAsReady(
|
||||||
|
pingInMs = response.receivedResponseAtMillis - response.sentRequestAtMillis,
|
||||||
|
usingCompression = response.headers.get("Sec-WebSocket-Extensions")?.contains("permessage-deflate") ?: false
|
||||||
|
)
|
||||||
|
|
||||||
// Log.w("Relay", "Relay OnOpen, Loading All subscriptions $url")
|
// Log.w("Relay", "Relay OnOpen, Loading All subscriptions $url")
|
||||||
onConnected(this@Relay)
|
onConnected(this@Relay)
|
||||||
@@ -178,15 +182,17 @@ class Relay(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markConnectionAsReady(pingInMs: Long) {
|
fun markConnectionAsReady(pingInMs: Long, usingCompression: Boolean) {
|
||||||
this.afterEOSE = false
|
this.afterEOSE = false
|
||||||
this.isReady = true
|
this.isReady = true
|
||||||
this.pingInMs = pingInMs
|
this.pingInMs = pingInMs
|
||||||
|
this.usingCompression = usingCompression
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markConnectionAsClosed() {
|
fun markConnectionAsClosed() {
|
||||||
this.socket = null
|
this.socket = null
|
||||||
this.isReady = false
|
this.isReady = false
|
||||||
|
this.usingCompression = false
|
||||||
this.afterEOSE = false
|
this.afterEOSE = false
|
||||||
this.closingTimeInSeconds = TimeUtils.now()
|
this.closingTimeInSeconds = TimeUtils.now()
|
||||||
}
|
}
|
||||||
@@ -242,6 +248,7 @@ class Relay(
|
|||||||
socket?.close(1000, "Normal close")
|
socket?.close(1000, "Normal close")
|
||||||
socket = null
|
socket = null
|
||||||
isReady = false
|
isReady = false
|
||||||
|
usingCompression = false
|
||||||
afterEOSE = false
|
afterEOSE = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user