mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Updated submodules and implemented timer to make sync connect requests less frequent upon failure.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Submodule app/src/stable/assets/sources/bilibili updated: 31490e10f9...5809463f3d
Submodule app/src/stable/assets/sources/bitchute updated: 872bfa2d75...4309c58008
Submodule app/src/stable/assets/sources/dailymotion updated: 069aa3d31a...6dc9ba2b61
Submodule app/src/stable/assets/sources/spotify updated: 4d554e9388...b94d5a5091
Submodule app/src/stable/assets/sources/youtube updated: 35b56d380a...95ae01d535
Submodule app/src/unstable/assets/sources/bilibili updated: 31490e10f9...5809463f3d
Submodule app/src/unstable/assets/sources/bitchute updated: 872bfa2d75...4309c58008
Submodule app/src/unstable/assets/sources/dailymotion updated: 069aa3d31a...6dc9ba2b61
Submodule app/src/unstable/assets/sources/spotify updated: 4d554e9388...b94d5a5091
Submodule app/src/unstable/assets/sources/youtube updated: dda3c6c719...95ae01d535
+1
-1
Submodule dep/polycentricandroid updated: a7063a300c...f7d58c6ca6
Reference in New Issue
Block a user