From 82dbb3a1f0400be77ba1cef5c4bf83d6fe6331d4 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 16 Aug 2023 20:27:23 +0300 Subject: [PATCH] broadcast -> send --- .../kotlin/space/kscience/controls/client/DeviceClient.kt | 4 ++-- .../kotlin/space/kscience/controls/client/controlsMagix.kt | 4 ++-- .../kotlin/space/kscience/controls/client/tangoMagix.kt | 4 ++-- .../kotlin/space/kscience/magix/api/MagixEndpoint.kt | 2 +- .../kotlin/space/kscience/magix/api/MagixFormat.kt | 2 +- .../kotlin/space/kscience/magix/services/MagixRegistry.kt | 6 +++--- .../kotlin/space/kscience/magix/storage/historyEndpoint.kt | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/DeviceClient.kt b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/DeviceClient.kt index a724fd6..ce5dd75 100644 --- a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/DeviceClient.kt +++ b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/DeviceClient.kt @@ -12,7 +12,7 @@ import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name import space.kscience.magix.api.MagixEndpoint -import space.kscience.magix.api.broadcast +import space.kscience.magix.api.send import space.kscience.magix.api.subscribe import kotlin.coroutines.CoroutineContext @@ -108,6 +108,6 @@ public class DeviceClient( public fun MagixEndpoint.remoteDevice(context: Context, magixTarget: String, deviceName: Name): DeviceClient { val subscription = subscribe(DeviceManager.magixFormat, originFilter = listOf(magixTarget)).map { it.second } return DeviceClient(context, deviceName, subscription) { - broadcast(DeviceManager.magixFormat, it, magixTarget, id = stringUID()) + send(DeviceManager.magixFormat, it, magixTarget, id = stringUID()) } } \ No newline at end of file diff --git a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt index c129c79..e986fc5 100644 --- a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt +++ b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt @@ -40,7 +40,7 @@ public fun DeviceManager.connectToMagix( endpoint.subscribe(controlsMagixFormat, targetFilter = listOf(endpointID)).onEach { (request, payload) -> val responsePayload = respondHubMessage(payload) if (responsePayload != null) { - endpoint.broadcast( + endpoint.send( format = controlsMagixFormat, target = request.sourceEndpoint, origin = endpointID, @@ -54,7 +54,7 @@ public fun DeviceManager.connectToMagix( }.launchIn(this) hubMessageFlow(this).onEach { payload -> - endpoint.broadcast( + endpoint.send( format = controlsMagixFormat, origin = endpointID, payload = payload, diff --git a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/tangoMagix.kt b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/tangoMagix.kt index 48ae3c5..e7ee969 100644 --- a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/tangoMagix.kt +++ b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/tangoMagix.kt @@ -75,7 +75,7 @@ public fun DeviceManager.launchTangoMagix( ): Job { suspend fun respond(request: MagixMessage, payload: TangoPayload, payloadBuilder: (TangoPayload) -> TangoPayload) { - endpoint.broadcast( + endpoint.send( tangoMagixFormat, id = generateId(request), parentId = request.id, @@ -125,7 +125,7 @@ public fun DeviceManager.launchTangoMagix( } } catch (ex: Exception) { logger.error(ex) { "Error while responding to message" } - endpoint.broadcast( + endpoint.send( tangoMagixFormat, id = generateId(request), parentId = request.id, diff --git a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixEndpoint.kt b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixEndpoint.kt index e1ccc23..19cf2f5 100644 --- a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixEndpoint.kt +++ b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixEndpoint.kt @@ -56,6 +56,6 @@ public interface MagixEndpoint { } /** - * An alias for [MagixEndpoint.broadcast] + * An alias for [MagixEndpoint.send] */ public suspend fun MagixEndpoint.send(message: MagixMessage): Unit = broadcast(message) \ No newline at end of file diff --git a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt index d1a02e8..39ef071 100644 --- a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt +++ b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt @@ -38,7 +38,7 @@ public fun MagixEndpoint.subscribe( * Send a message using given [format] to encode the message payload. The format field is also taken from [format]. * */ -public suspend fun MagixEndpoint.broadcast( +public suspend fun MagixEndpoint.send( format: MagixFormat, payload: T, target: String? = null, diff --git a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/services/MagixRegistry.kt b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/services/MagixRegistry.kt index 993d246..e82dc24 100644 --- a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/services/MagixRegistry.kt +++ b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/services/MagixRegistry.kt @@ -10,7 +10,7 @@ import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonNull import space.kscience.magix.api.MagixEndpoint import space.kscience.magix.api.MagixFormat -import space.kscience.magix.api.broadcast +import space.kscience.magix.api.send import space.kscience.magix.api.subscribe /** @@ -67,12 +67,12 @@ public fun CoroutineScope.launchMagixRegistry( if (payload is MagixRegistryRequestMessage) { try { val value = registry.request(payload.propertyName, magixMessage.user) - endpoint.broadcast( + endpoint.send( MagixRegistryMessage.format, MagixRegistryValueMessage(payload.propertyName, value ?: JsonNull) ) } catch (ex: Exception){ - endpoint.broadcast( + endpoint.send( MagixRegistryMessage.format, MagixRegistryErrorMessage(payload.propertyName, ex::class.simpleName, ex.message) ) diff --git a/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt b/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt index 67b2cd3..c0ec3f9 100644 --- a/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt +++ b/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonPrimitive import space.kscience.magix.api.MagixEndpoint import space.kscience.magix.api.MagixMessage -import space.kscience.magix.api.broadcast +import space.kscience.magix.api.send import space.kscience.magix.api.subscribe internal fun generateId(request: MagixMessage): String = if (request.id != null) { @@ -47,7 +47,7 @@ public fun MagixEndpoint.launchHistory( pageNumber, lastPage = end ) - broadcast( + send( format = MagixHistory.magixFormat, payload = sendPayload, target = request.sourceEndpoint,