Dev #8

Merged
altavir merged 78 commits from dev into master 2023-03-04 16:47:55 +03:00
8 changed files with 41 additions and 11 deletions
Showing only changes of commit 879073e339 - Show all commits

View File

@ -1,5 +1,6 @@
plugins {
id("ru.mipt.npm.gradle.mpp")
id("ru.mipt.npm.gradle.native")
`maven-publish`
}

View File

@ -67,7 +67,7 @@ suspend fun MagixEndpoint.startDemoDeviceServer(): ApplicationEngine = embeddedS
val cosFlow = MutableSharedFlow<Meta?>()// = device.cos.flow()
launch {
subscribe(controlsMagixFormat).collect { (magix, payload) ->
subscribe(controlsMagixFormat).collect { (_, payload) ->
(payload as? PropertyChangedMessage)?.let { message ->
when (message.property) {
"sin" -> sinFlow.emit(message.value)

View File

@ -30,9 +30,9 @@ public interface MagixClient<T> {
*
* @param host host name of magix server event loop
* @param port port of magix server event loop
* @param path
* @param path context path for WS connection
*/
static MagixClient<JsonElement> rSocketWs(String host, int port, String path) {
return ControlsMagixClient.Companion.rSocketWs(host, port, JsonElement.Companion.serializer(), path);
return ControlsMagixClient.Companion.rSocketWs(host, port, path);
}
}

View File

@ -2,7 +2,6 @@ package ru.mipt.npm.magix.client
import kotlinx.coroutines.jdk9.asPublisher
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.KSerializer
import ru.mipt.npm.magix.api.MagixEndpoint
import ru.mipt.npm.magix.api.MagixMessage
import ru.mipt.npm.magix.api.MagixMessageFilter
@ -36,7 +35,6 @@ internal class ControlsMagixClient<T>(
fun <T> rSocketWs(
host: String,
port: Int,
payloadSerializer: KSerializer<T>,
path: String = "/rsocket"
): ControlsMagixClient<T> {
val endpoint = runBlocking {

View File

@ -26,9 +26,13 @@ kotlin {
implementation("io.rsocket.kotlin:rsocket-ktor-client:$rsocketVersion")
}
}
jvmMain{
dependencies{
implementation("io.ktor:ktor-network:$ktorVersion")
jvmMain {
dependencies {
implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion")
}
}
linuxX64Main{
dependencies {
implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion")
}
}

View File

@ -1,7 +1,6 @@
package ru.mipt.npm.magix.rsocket
import io.ktor.network.sockets.SocketOptions
import io.ktor.util.InternalAPI
import io.rsocket.kotlin.core.RSocketConnectorBuilder
import io.rsocket.kotlin.transport.ktor.tcp.TcpClientTransport
import ru.mipt.npm.magix.api.MagixEndpoint
@ -11,7 +10,6 @@ import kotlin.coroutines.coroutineContext
/**
* Create a plain TCP based [RSocketMagixEndpoint] connected to [host] and [port]
*/
@OptIn(InternalAPI::class)
public suspend fun MagixEndpoint.Companion.rSocketWithTcp(
host: String,
port: Int = DEFAULT_MAGIX_RAW_PORT,

View File

@ -0,0 +1,29 @@
package rsocket
import io.ktor.network.sockets.SocketOptions
import io.rsocket.kotlin.core.RSocketConnectorBuilder
import io.rsocket.kotlin.transport.ktor.tcp.TcpClientTransport
import ru.mipt.npm.magix.api.MagixEndpoint
import ru.mipt.npm.magix.rsocket.RSocketMagixEndpoint
import ru.mipt.npm.magix.rsocket.buildConnector
import kotlin.coroutines.coroutineContext
/**
* Create a plain TCP based [RSocketMagixEndpoint] connected to [host] and [port]
*/
public suspend fun MagixEndpoint.Companion.rSocketWithTcp(
host: String,
port: Int = DEFAULT_MAGIX_RAW_PORT,
tcpConfig: SocketOptions.TCPClientSocketOptions.() -> Unit = {},
rSocketConfig: RSocketConnectorBuilder.ConnectionConfigBuilder.() -> Unit = {},
): RSocketMagixEndpoint {
val transport = TcpClientTransport(
hostname = host,
port = port,
configure = tcpConfig
)
val rSocket = buildConnector(rSocketConfig).connect(transport)
return RSocketMagixEndpoint(rSocket, coroutineContext)
}

View File

@ -19,7 +19,7 @@ val rsocketVersion: String by rootProject.extra
val ktorVersion: String = ru.mipt.npm.gradle.KScienceVersions.ktorVersion
dependencies{
api(project(":magix:magix-api"))
api(projects.magix.magixApi)
api("io.ktor:ktor-server-cio:$ktorVersion")
api("io.ktor:ktor-server-websockets:$ktorVersion")
api("io.ktor:ktor-server-content-negotiation:$ktorVersion")