Update FcastManager.kt

This commit is contained in:
CranberrySoup 2024-08-02 01:29:45 +00:00 committed by GitHub
parent ff29fe6ee6
commit 1666677baf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,7 +79,9 @@ class FcastManager {
override fun onServiceResolved(serviceInfo: NsdServiceInfo?) {
if (serviceInfo == null) return
currentDevices.add(PublicDeviceInfo(serviceInfo))
synchronized(_currentDevices) {
_currentDevices.add(PublicDeviceInfo(serviceInfo))
}
Log.d(
tag,
@ -93,9 +95,11 @@ class FcastManager {
if (serviceInfo == null) return
// May remove duplicates, but net and port is null here, preventing device specific identification
currentDevices.removeAll {
synchronized(_currentDevices) {
_currentDevices.removeAll {
it.rawName == serviceInfo.serviceName
}
}
Log.d(tag, "Service lost: ${serviceInfo.serviceName}")
}
@ -103,7 +107,8 @@ class FcastManager {
companion object {
const val APP_PREFIX = "CloudStream"
val currentDevices: MutableList<PublicDeviceInfo> = mutableListOf()
private val _currentDevices: MutableList<PublicDeviceInfo> = mutableListOf()
val currentDevices: List<PublicDeviceInfo> = _currentDevices
class DefaultRegistrationListener : NsdManager.RegistrationListener {
val tag = "DiscoveryService"