mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-19 19:14:51 +00:00
Updated submodules and implemented timer to make sync connect requests less frequent upon failure.
This commit is contained in:
parent
790331e798
commit
ea1ac86134
12 changed files with 33 additions and 18 deletions
|
@ -53,7 +53,8 @@ class StateSync {
|
|||
private var _connectThread: Thread? = null
|
||||
private var _started = false
|
||||
private val _sessions: MutableMap<String, SyncSession> = mutableMapOf()
|
||||
private val _lastConnectTimes: MutableMap<String, Long> = mutableMapOf()
|
||||
private val _lastConnectTimesMdns: MutableMap<String, Long> = mutableMapOf()
|
||||
private val _lastConnectTimesIp: MutableMap<String, Long> = mutableMapOf()
|
||||
//TODO: Should sync mdns and casting mdns be merged?
|
||||
//TODO: Decrease interval that devices are updated
|
||||
//TODO: Send less data
|
||||
|
@ -148,7 +149,21 @@ class StateSync {
|
|||
for (connectPair in addressesToConnect) {
|
||||
try {
|
||||
val syncDeviceInfo = SyncDeviceInfo(connectPair.first, arrayOf(connectPair.second), PORT)
|
||||
connect(syncDeviceInfo)
|
||||
|
||||
val now = System.currentTimeMillis()
|
||||
val lastConnectTime = synchronized(_lastConnectTimesIp) {
|
||||
_lastConnectTimesIp[connectPair.first] ?: 0
|
||||
}
|
||||
|
||||
//Connect once every 30 seconds, max
|
||||
if (now - lastConnectTime > 30000) {
|
||||
synchronized(_lastConnectTimesIp) {
|
||||
_lastConnectTimesIp[connectPair.first] = now
|
||||
}
|
||||
|
||||
Logger.i(TAG, "Attempting to connect to authorized device by last known IP '${connectPair.first}' with pkey=${connectPair.first}")
|
||||
connect(syncDeviceInfo)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Logger.i(TAG, "Failed to connect to " + connectPair.first, e)
|
||||
}
|
||||
|
@ -222,14 +237,14 @@ class StateSync {
|
|||
|
||||
if (authorized && !isConnected(pkey)) {
|
||||
val now = System.currentTimeMillis()
|
||||
val lastConnectTime = synchronized(_lastConnectTimes) {
|
||||
_lastConnectTimes[pkey] ?: 0
|
||||
val lastConnectTime = synchronized(_lastConnectTimesMdns) {
|
||||
_lastConnectTimesMdns[pkey] ?: 0
|
||||
}
|
||||
|
||||
//Connect once every 30 seconds, max
|
||||
if (now - lastConnectTime > 30000) {
|
||||
synchronized(_lastConnectTimes) {
|
||||
_lastConnectTimes[pkey] = now
|
||||
synchronized(_lastConnectTimesMdns) {
|
||||
_lastConnectTimesMdns[pkey] = now
|
||||
}
|
||||
|
||||
Logger.i(TAG, "Found device authorized device '${name}' with pkey=$pkey, attempting to connect")
|
||||
|
@ -237,7 +252,7 @@ class StateSync {
|
|||
try {
|
||||
connect(syncDeviceInfo)
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to connect to $pkey", e)
|
||||
Logger.i(TAG, "Failed to connect to $pkey", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 31490e10f9ef661d6365c0cf4d0fcedf9d807a69
|
||||
Subproject commit 5809463f3dc2fd81fb92740ede467e271b5ca0c3
|
|
@ -1 +1 @@
|
|||
Subproject commit 872bfa2d758317c4d0989d309966e85ceb4fcb29
|
||||
Subproject commit 4309c58008b92bdf2905ef05bf9129b50eab1edd
|
|
@ -1 +1 @@
|
|||
Subproject commit 069aa3d31a35559e45c1fe1ea1eb2a94d3b5d120
|
||||
Subproject commit 6dc9ba2b61ed885ec48e06e319ba75fe9bff942c
|
|
@ -1 +1 @@
|
|||
Subproject commit 4d554e93882d29542cb05d2956f4b2484d7df27f
|
||||
Subproject commit b94d5a5091ae0929d82c703868616158607a4436
|
|
@ -1 +1 @@
|
|||
Subproject commit 35b56d380a9ae6ef85ba8ec16cecb0a86d4efa1d
|
||||
Subproject commit 95ae01d5358328583fc3a3b59a2a0ca9d06301d2
|
|
@ -1 +1 @@
|
|||
Subproject commit 31490e10f9ef661d6365c0cf4d0fcedf9d807a69
|
||||
Subproject commit 5809463f3dc2fd81fb92740ede467e271b5ca0c3
|
|
@ -1 +1 @@
|
|||
Subproject commit 872bfa2d758317c4d0989d309966e85ceb4fcb29
|
||||
Subproject commit 4309c58008b92bdf2905ef05bf9129b50eab1edd
|
|
@ -1 +1 @@
|
|||
Subproject commit 069aa3d31a35559e45c1fe1ea1eb2a94d3b5d120
|
||||
Subproject commit 6dc9ba2b61ed885ec48e06e319ba75fe9bff942c
|
|
@ -1 +1 @@
|
|||
Subproject commit 4d554e93882d29542cb05d2956f4b2484d7df27f
|
||||
Subproject commit b94d5a5091ae0929d82c703868616158607a4436
|
|
@ -1 +1 @@
|
|||
Subproject commit dda3c6c71948be5e40b1704895eacf796753e953
|
||||
Subproject commit 95ae01d5358328583fc3a3b59a2a0ca9d06301d2
|
|
@ -1 +1 @@
|
|||
Subproject commit a7063a300c40dd2310325716f2300ac9259f47aa
|
||||
Subproject commit f7d58c6ca6de151c11bd4ecc48a7de81bdc36d8a
|
Loading…
Add table
Reference in a new issue