Fix visibility range for collective

This commit is contained in:
Alexander Nozik 2024-06-09 21:12:18 +03:00
parent c55ce2cf9a
commit 60a693b1b3
3 changed files with 10 additions and 5 deletions

View File

@ -44,7 +44,7 @@ internal fun VirtualDeviceState(
internal class DeviceCollectiveModel( internal class DeviceCollectiveModel(
context: Context, context: Context,
val deviceStates: Collection<CollectiveDeviceState>, val deviceStates: Collection<CollectiveDeviceState>,
val visibilityRange: Distance = 1.kilometers, val visibilityRange: Distance = 0.5.kilometers,
val radioRange: Distance = 5.kilometers, val radioRange: Distance = 5.kilometers,
) : ModelConstructor(context), PeerConnection { ) : ModelConstructor(context), PeerConnection {

View File

@ -44,7 +44,7 @@ internal fun generateModel(
} }
} }
val model = DeviceCollectiveModel(context, devices, 0.2.kilometers) val model = DeviceCollectiveModel(context, devices)
return model return model
} }

View File

@ -51,6 +51,7 @@ import space.kscience.maps.coordinates.Gmc
import space.kscience.maps.coordinates.meters import space.kscience.maps.coordinates.meters
import space.kscience.maps.features.* import space.kscience.maps.features.*
import java.nio.file.Path import java.nio.file.Path
import kotlin.time.Duration.Companion.seconds
@Composable @Composable
@ -69,7 +70,7 @@ fun App() {
} }
val collectiveModel = remember { val collectiveModel = remember {
generateModel(parentContext, 60) generateModel(parentContext, 100, reportInterval = 1.seconds)
} }
val roster = remember { val roster = remember {
@ -83,12 +84,16 @@ fun App() {
LaunchedEffect(collectiveModel) { LaunchedEffect(collectiveModel) {
launchCollectiveMagixServer(collectiveModel) launchCollectiveMagixServer(collectiveModel)
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val magixClient = MagixEndpoint.rSocketWithWebSockets("localhost") val magixClient = MagixEndpoint.rSocketWithWebSockets("localhost")
client.complete(magixClient) client.complete(magixClient)
collectiveModel.roster.forEach { (id, config) ->
devices[id] = magixClient.remoteDevice(parentContext, "listener", id, id.parseAsName()) collectiveModel.roster.forEach { (id, config) ->
scope.launch {
devices[id] = magixClient.remoteDevice(parentContext, "listener", id, id.parseAsName())
}
} }
} }