mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Update FcastManager.kt (#1244)
This commit is contained in:
parent
15b5013e28
commit
7936ccf5d3
1 changed files with 10 additions and 5 deletions
|
@ -79,7 +79,9 @@ class FcastManager {
|
||||||
override fun onServiceResolved(serviceInfo: NsdServiceInfo?) {
|
override fun onServiceResolved(serviceInfo: NsdServiceInfo?) {
|
||||||
if (serviceInfo == null) return
|
if (serviceInfo == null) return
|
||||||
|
|
||||||
currentDevices.add(PublicDeviceInfo(serviceInfo))
|
synchronized(_currentDevices) {
|
||||||
|
_currentDevices.add(PublicDeviceInfo(serviceInfo))
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(
|
Log.d(
|
||||||
tag,
|
tag,
|
||||||
|
@ -93,8 +95,10 @@ class FcastManager {
|
||||||
if (serviceInfo == null) return
|
if (serviceInfo == null) return
|
||||||
|
|
||||||
// May remove duplicates, but net and port is null here, preventing device specific identification
|
// May remove duplicates, but net and port is null here, preventing device specific identification
|
||||||
currentDevices.removeAll {
|
synchronized(_currentDevices) {
|
||||||
it.rawName == serviceInfo.serviceName
|
_currentDevices.removeAll {
|
||||||
|
it.rawName == serviceInfo.serviceName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(tag, "Service lost: ${serviceInfo.serviceName}")
|
Log.d(tag, "Service lost: ${serviceInfo.serviceName}")
|
||||||
|
@ -103,7 +107,8 @@ class FcastManager {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val APP_PREFIX = "CloudStream"
|
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 {
|
class DefaultRegistrationListener : NsdManager.RegistrationListener {
|
||||||
val tag = "DiscoveryService"
|
val tag = "DiscoveryService"
|
||||||
|
@ -132,4 +137,4 @@ class PublicDeviceInfo(serviceInfo: NsdServiceInfo) {
|
||||||
val rawName: String = serviceInfo.serviceName
|
val rawName: String = serviceInfo.serviceName
|
||||||
val host: String? = serviceInfo.host.hostAddress
|
val host: String? = serviceInfo.host.hostAddress
|
||||||
val name = rawName.replace("-", " ") + host?.let { " $it" }
|
val name = rawName.replace("-", " ") + host?.let { " $it" }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue