Update dependencies
This commit is contained in:
parent
2e7eefeba9
commit
3d0b888c11
@ -2,9 +2,9 @@ plugins {
|
||||
id("ru.mipt.npm.gradle.project")
|
||||
}
|
||||
|
||||
val dataforgeVersion: String by extra("0.5.1")
|
||||
val dataforgeVersion: String by extra("0.5.2")
|
||||
val ktorVersion: String by extra(ru.mipt.npm.gradle.KScienceVersions.ktorVersion)
|
||||
val rsocketVersion by extra("0.13.1")
|
||||
val rsocketVersion by extra("0.15.4")
|
||||
|
||||
allprojects {
|
||||
group = "ru.mipt.npm"
|
||||
|
@ -39,8 +39,8 @@ public suspend inline fun <reified T: Any> MiloDevice.readOpcWithTime(
|
||||
val time = data.serverTime ?: error("No server time provided")
|
||||
val meta: Meta = when (val content = data.value.value) {
|
||||
is T -> return content to time
|
||||
content is Meta -> content as Meta
|
||||
content is ExtensionObject -> (content as ExtensionObject).decode(client.dynamicSerializationContext) as Meta
|
||||
is Meta -> content
|
||||
is ExtensionObject -> content.decode(client.dynamicSerializationContext) as Meta
|
||||
else -> error("Incompatible OPC property value $content")
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,9 @@ dependencies {
|
||||
implementation(project(":controls-tcp"))
|
||||
implementation(projects.magix.magixServer)
|
||||
implementation("io.ktor:ktor-server-cio:$ktorVersion")
|
||||
implementation("io.ktor:ktor-websockets:$ktorVersion")
|
||||
implementation("io.ktor:ktor-serialization:$ktorVersion")
|
||||
implementation("io.ktor:ktor-html-builder:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-websockets:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-html-builder:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-status-pages:$ktorVersion")
|
||||
}
|
@ -1,24 +1,23 @@
|
||||
package ru.mipt.npm.controls.server
|
||||
|
||||
|
||||
import io.ktor.application.*
|
||||
import io.ktor.features.CORS
|
||||
import io.ktor.features.StatusPages
|
||||
import io.ktor.html.respondHtml
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.request.receiveText
|
||||
import io.ktor.response.respond
|
||||
import io.ktor.response.respondRedirect
|
||||
import io.ktor.response.respondText
|
||||
import io.ktor.routing.get
|
||||
import io.ktor.routing.post
|
||||
import io.ktor.routing.route
|
||||
import io.ktor.routing.routing
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.cio.CIO
|
||||
import io.ktor.server.engine.ApplicationEngine
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import io.ktor.util.getValue
|
||||
import io.ktor.websocket.WebSockets
|
||||
import io.ktor.server.html.respondHtml
|
||||
import io.ktor.server.plugins.statuspages.StatusPages
|
||||
import io.ktor.server.request.receiveText
|
||||
import io.ktor.server.response.respond
|
||||
import io.ktor.server.response.respondRedirect
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.get
|
||||
import io.ktor.server.routing.post
|
||||
import io.ktor.server.routing.route
|
||||
import io.ktor.server.routing.routing
|
||||
import io.ktor.server.util.getValue
|
||||
import io.ktor.server.websocket.WebSockets
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.html.*
|
||||
@ -52,11 +51,11 @@ public fun CoroutineScope.startDeviceServer(
|
||||
|
||||
return this.embeddedServer(CIO, port, host) {
|
||||
install(WebSockets)
|
||||
install(CORS) {
|
||||
anyHost()
|
||||
}
|
||||
// install(CORS) {
|
||||
// anyHost()
|
||||
// }
|
||||
install(StatusPages) {
|
||||
exception<IllegalArgumentException> { cause ->
|
||||
exception<IllegalArgumentException> { call, cause ->
|
||||
call.respond(HttpStatusCode.BadRequest, cause.message ?: "")
|
||||
}
|
||||
}
|
||||
@ -83,15 +82,15 @@ public fun Application.deviceManagerModule(
|
||||
rawSocketPort: Int = MagixEndpoint.DEFAULT_MAGIX_RAW_PORT,
|
||||
buffer: Int = 100,
|
||||
) {
|
||||
if (featureOrNull(WebSockets) == null) {
|
||||
if (pluginOrNull(WebSockets) == null) {
|
||||
install(WebSockets)
|
||||
}
|
||||
|
||||
if (featureOrNull(CORS) == null) {
|
||||
install(CORS) {
|
||||
anyHost()
|
||||
}
|
||||
}
|
||||
// if (pluginOrNull(CORS) == null) {
|
||||
// install(CORS) {
|
||||
// anyHost()
|
||||
// }
|
||||
// }
|
||||
|
||||
routing {
|
||||
route(route) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package ru.mipt.npm.controls.server
|
||||
|
||||
import io.ktor.application.ApplicationCall
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.response.respondText
|
||||
import io.ktor.server.application.ApplicationCall
|
||||
import io.ktor.server.response.respondText
|
||||
import kotlinx.serialization.json.JsonObjectBuilder
|
||||
import kotlinx.serialization.json.buildJsonObject
|
||||
import ru.mipt.npm.controls.api.DeviceMessage
|
||||
|
@ -1,6 +1,6 @@
|
||||
package ru.mipt.npm.controls.storage
|
||||
|
||||
import io.ktor.application.Application
|
||||
import io.ktor.server.application.Application
|
||||
import kotlinx.coroutines.InternalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
@ -1,17 +1,10 @@
|
||||
plugins {
|
||||
id("ru.mipt.npm.gradle.mpp")
|
||||
id("ru.mipt.npm.gradle.jvm")
|
||||
}
|
||||
|
||||
val ktorVersion: String by rootProject.extra
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
dependencies {
|
||||
api(project(":controls-core"))
|
||||
api("io.ktor:ktor-network:$ktorVersion")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ import space.kscience.dataforge.meta.Meta
|
||||
import space.kscience.dataforge.meta.get
|
||||
import space.kscience.dataforge.meta.int
|
||||
import space.kscience.dataforge.meta.string
|
||||
import java.net.InetSocketAddress
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
public class KtorTcpPort internal constructor(
|
||||
@ -29,7 +28,7 @@ public class KtorTcpPort internal constructor(
|
||||
override fun toString(): String = "port[tcp:$host:$port]"
|
||||
|
||||
private val futureSocket = scope.async {
|
||||
aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().connect(InetSocketAddress(host, port))
|
||||
aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().connect(host, port)
|
||||
}
|
||||
|
||||
private val writeChannel = scope.async {
|
@ -1,15 +1,13 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("org.openjfx.javafxplugin") version "0.0.9"
|
||||
id("org.openjfx.javafxplugin") version "0.0.10"
|
||||
application
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven("https://repo.kotlin.link")
|
||||
maven("https://kotlin.bintray.com/kotlinx")
|
||||
}
|
||||
|
||||
val ktorVersion: String by rootProject.extra
|
||||
@ -26,9 +24,9 @@ dependencies {
|
||||
|
||||
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
||||
implementation("no.tornado:tornadofx:1.7.20")
|
||||
implementation("space.kscience:plotlykt-server:0.5.0-dev-1")
|
||||
implementation("com.github.Ricky12Awesome:json-schema-serialization:0.6.6")
|
||||
implementation("ch.qos.logback:logback-classic:1.2.3")
|
||||
implementation("space.kscience:plotlykt-server:0.5.2-dev-2")
|
||||
// implementation("com.github.Ricky12Awesome:json-schema-serialization:0.6.6")
|
||||
implementation("ch.qos.logback:logback-classic:1.2.11")
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
|
@ -26,8 +26,8 @@ dependencies {
|
||||
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.1")
|
||||
implementation("no.tornado:tornadofx:1.7.20")
|
||||
implementation("space.kscience:plotlykt-server:0.5.0-dev-1")
|
||||
implementation("ch.qos.logback:logback-classic:1.2.3")
|
||||
implementation("space.kscience:plotlykt-server:0.5.0")
|
||||
implementation("ch.qos.logback:logback-classic:1.2.11")
|
||||
implementation("org.jetbrains.xodus:xodus-entity-store:1.3.232")
|
||||
implementation("org.jetbrains.xodus:xodus-environment:1.3.232")
|
||||
implementation("org.jetbrains.xodus:xodus-vfs:1.3.232")
|
||||
@ -46,6 +46,6 @@ javafx {
|
||||
modules("javafx.controls")
|
||||
}
|
||||
|
||||
//application {
|
||||
// mainClass.set("ru.mipt.npm.controls.demo.DemoControllerViewKt")
|
||||
//}
|
||||
application {
|
||||
mainClass.set("ru.mipt.npm.controls.demo.car.VirtualCarControllerKt")
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package ru.mipt.npm.controls.demo
|
||||
|
||||
import io.ktor.application.install
|
||||
import io.ktor.features.CORS
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.cio.CIO
|
||||
import io.ktor.server.engine.ApplicationEngine
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import io.ktor.websocket.WebSockets
|
||||
import io.rsocket.kotlin.transport.ktor.server.RSocketSupport
|
||||
import io.ktor.server.plugins.cors.routing.CORS
|
||||
import io.ktor.server.websocket.WebSockets
|
||||
import io.rsocket.kotlin.ktor.server.RSocketSupport
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.html.div
|
||||
@ -54,8 +54,7 @@ suspend fun Trace.updateXYFrom(flow: Flow<Iterable<Pair<Double, Double>>>) {
|
||||
}
|
||||
|
||||
|
||||
suspend fun MagixEndpoint<DeviceMessage>.startDemoDeviceServer(): ApplicationEngine =
|
||||
embeddedServer(CIO, 9090) {
|
||||
suspend fun MagixEndpoint<DeviceMessage>.startDemoDeviceServer(): ApplicationEngine = embeddedServer(CIO, 9090) {
|
||||
install(WebSockets)
|
||||
install(RSocketSupport)
|
||||
|
||||
@ -77,10 +76,10 @@ suspend fun MagixEndpoint<DeviceMessage>.startDemoDeviceServer(): ApplicationEng
|
||||
}
|
||||
}
|
||||
|
||||
plotlyModule().apply {
|
||||
plotlyModule{
|
||||
updateMode = PlotlyUpdateMode.PUSH
|
||||
updateInterval = 50
|
||||
}.page { container ->
|
||||
page { container ->
|
||||
val sinCosFlow = sinFlow.zip(cosFlow) { sin, cos ->
|
||||
sin.double!! to cos.double!!
|
||||
}
|
||||
@ -140,6 +139,8 @@ suspend fun MagixEndpoint<DeviceMessage>.startDemoDeviceServer(): ApplicationEng
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.apply { start() }
|
||||
|
||||
}
|
||||
}
|
||||
}.apply { start() }
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package ru.mipt.npm.controls.demo
|
||||
|
||||
import com.github.ricky12awesome.jss.encodeToSchema
|
||||
import com.github.ricky12awesome.jss.globalJson
|
||||
import ru.mipt.npm.controls.api.DeviceMessage
|
||||
//import com.github.ricky12awesome.jss.encodeToSchema
|
||||
//import com.github.ricky12awesome.jss.globalJson
|
||||
//import ru.mipt.npm.controls.api.DeviceMessage
|
||||
|
||||
fun main() {
|
||||
val schema = globalJson.encodeToSchema(DeviceMessage.serializer(), generateDefinitions = false)
|
||||
println(schema)
|
||||
}
|
||||
//fun main() {
|
||||
// val schema = globalJson.encodeToSchema(DeviceMessage.serializer(), generateDefinitions = false)
|
||||
// println(schema)
|
||||
//}
|
@ -3,10 +3,9 @@ kotlin.mpp.stability.nowarn=true
|
||||
|
||||
kotlin.jupyter.add.scanner=false
|
||||
|
||||
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G
|
||||
org.gradle.parallel=true
|
||||
|
||||
publishing.github=false
|
||||
publishing.sonatype=false
|
||||
|
||||
toolsVersion=0.10.9-kotlin-1.6.10
|
||||
toolsVersion=0.11.5-kotlin-1.6.21
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -8,3 +8,8 @@ dependencies {
|
||||
implementation(project(":magix:magix-rsocket"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk9:${ru.mipt.npm.gradle.KScienceVersions.coroutinesVersion}")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
@ -22,7 +22,13 @@ kotlin {
|
||||
dependencies {
|
||||
api(projects.magix.magixApi)
|
||||
implementation("io.ktor:ktor-client-core:$ktorVersion")
|
||||
implementation("io.rsocket.kotlin:rsocket-transport-ktor-client:$rsocketVersion")
|
||||
implementation("io.rsocket.kotlin:rsocket-ktor-client:$rsocketVersion")
|
||||
}
|
||||
}
|
||||
jvmMain{
|
||||
dependencies{
|
||||
implementation("io.ktor:ktor-network:$ktorVersion")
|
||||
implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
package ru.mipt.npm.magix.rsocket
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.features.websocket.WebSockets
|
||||
import io.ktor.client.plugins.websocket.WebSockets
|
||||
import io.rsocket.kotlin.RSocket
|
||||
import io.rsocket.kotlin.core.RSocketConnector
|
||||
import io.rsocket.kotlin.core.RSocketConnectorBuilder
|
||||
import io.rsocket.kotlin.ktor.client.RSocketSupport
|
||||
import io.rsocket.kotlin.ktor.client.rSocket
|
||||
import io.rsocket.kotlin.payload.buildPayload
|
||||
import io.rsocket.kotlin.payload.data
|
||||
import io.rsocket.kotlin.transport.ktor.client.RSocketSupport
|
||||
import io.rsocket.kotlin.transport.ktor.client.rSocket
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.map
|
||||
@ -79,7 +80,7 @@ public suspend fun <T> MagixEndpoint.Companion.rSocketWithWebSockets(
|
||||
val rSocket = client.rSocket(host, port, path)
|
||||
|
||||
//Ensure client is closed after rSocket if finished
|
||||
rSocket.job.invokeOnCompletion {
|
||||
rSocket.coroutineContext[Job]?.invokeOnCompletion {
|
||||
client.close()
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package ru.mipt.npm.magix.rsocket
|
||||
|
||||
import io.ktor.network.selector.ActorSelectorManager
|
||||
import io.ktor.network.sockets.SocketOptions
|
||||
import io.ktor.util.InternalAPI
|
||||
import io.rsocket.kotlin.core.RSocketConnectorBuilder
|
||||
import io.rsocket.kotlin.transport.ktor.TcpClientTransport
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import io.rsocket.kotlin.transport.ktor.tcp.TcpClientTransport
|
||||
import kotlinx.serialization.KSerializer
|
||||
import ru.mipt.npm.magix.api.MagixEndpoint
|
||||
import kotlin.coroutines.coroutineContext
|
||||
@ -23,7 +21,6 @@ public suspend fun <T> MagixEndpoint.Companion.rSocketWithTcp(
|
||||
rSocketConfig: RSocketConnectorBuilder.ConnectionConfigBuilder.() -> Unit = {},
|
||||
): RSocketMagixEndpoint<T> {
|
||||
val transport = TcpClientTransport(
|
||||
ActorSelectorManager(Dispatchers.IO),
|
||||
hostname = host,
|
||||
port = port,
|
||||
configure = tcpConfig
|
||||
|
@ -21,12 +21,13 @@ val ktorVersion: String = ru.mipt.npm.gradle.KScienceVersions.ktorVersion
|
||||
dependencies{
|
||||
api(project(":magix:magix-api"))
|
||||
api("io.ktor:ktor-server-cio:$ktorVersion")
|
||||
api("io.ktor:ktor-websockets:$ktorVersion")
|
||||
api("io.ktor:ktor-serialization:$ktorVersion")
|
||||
api("io.ktor:ktor-html-builder:$ktorVersion")
|
||||
api("io.ktor:ktor-server-websockets:$ktorVersion")
|
||||
api("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
||||
api("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
||||
api("io.ktor:ktor-server-html-builder:$ktorVersion")
|
||||
|
||||
api("io.rsocket.kotlin:rsocket-core:$rsocketVersion")
|
||||
api("io.rsocket.kotlin:rsocket-transport-ktor-server:$rsocketVersion")
|
||||
api("io.rsocket.kotlin:rsocket-ktor-server:$rsocketVersion")
|
||||
api("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion")
|
||||
|
||||
api("org.zeromq:jeromq:0.5.2")
|
||||
}
|
@ -1,24 +1,23 @@
|
||||
package ru.mipt.npm.magix.server
|
||||
|
||||
import io.ktor.application.*
|
||||
import io.ktor.features.CORS
|
||||
import io.ktor.features.ContentNegotiation
|
||||
import io.ktor.html.respondHtml
|
||||
import io.ktor.request.receive
|
||||
import io.ktor.routing.get
|
||||
import io.ktor.routing.post
|
||||
import io.ktor.routing.route
|
||||
import io.ktor.routing.routing
|
||||
import io.ktor.serialization.json
|
||||
import io.ktor.util.getValue
|
||||
import io.ktor.websocket.WebSockets
|
||||
import io.ktor.serialization.kotlinx.json.json
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.html.respondHtml
|
||||
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.server.request.receive
|
||||
import io.ktor.server.routing.get
|
||||
import io.ktor.server.routing.post
|
||||
import io.ktor.server.routing.route
|
||||
import io.ktor.server.routing.routing
|
||||
import io.ktor.server.util.getValue
|
||||
import io.ktor.server.websocket.WebSockets
|
||||
import io.rsocket.kotlin.ConnectionAcceptor
|
||||
import io.rsocket.kotlin.RSocketRequestHandler
|
||||
import io.rsocket.kotlin.ktor.server.RSocketSupport
|
||||
import io.rsocket.kotlin.ktor.server.rSocket
|
||||
import io.rsocket.kotlin.payload.Payload
|
||||
import io.rsocket.kotlin.payload.buildPayload
|
||||
import io.rsocket.kotlin.payload.data
|
||||
import io.rsocket.kotlin.transport.ktor.server.RSocketSupport
|
||||
import io.rsocket.kotlin.transport.ktor.server.rSocket
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.html.*
|
||||
@ -88,23 +87,23 @@ private fun ApplicationCall.buildFilter(): MagixMessageFilter {
|
||||
* Attache magix http/sse and websocket-based rsocket event loop + statistics page to existing [MutableSharedFlow]
|
||||
*/
|
||||
public fun Application.magixModule(magixFlow: MutableSharedFlow<GenericMagixMessage>, route: String = "/") {
|
||||
if (featureOrNull(WebSockets) == null) {
|
||||
if (pluginOrNull(WebSockets) == null) {
|
||||
install(WebSockets)
|
||||
}
|
||||
|
||||
if (featureOrNull(CORS) == null) {
|
||||
install(CORS) {
|
||||
//TODO consider more safe policy
|
||||
anyHost()
|
||||
}
|
||||
}
|
||||
if (featureOrNull(ContentNegotiation) == null) {
|
||||
// if (pluginOrNull(CORS) == null) {
|
||||
// install(CORS) {
|
||||
// //TODO consider more safe policy
|
||||
// anyHost()
|
||||
// }
|
||||
// }
|
||||
if (pluginOrNull(ContentNegotiation) == null) {
|
||||
install(ContentNegotiation) {
|
||||
json()
|
||||
}
|
||||
}
|
||||
|
||||
if (featureOrNull(RSocketSupport) == null) {
|
||||
if (pluginOrNull(RSocketSupport) == null) {
|
||||
install(RSocketSupport)
|
||||
}
|
||||
|
||||
@ -150,7 +149,7 @@ public fun Application.magixModule(magixFlow: MutableSharedFlow<GenericMagixMess
|
||||
magixFlow.emit(message)
|
||||
}
|
||||
//rSocket server. Filter from Payload
|
||||
rSocket("rsocket", acceptor = magixAcceptor(magixFlow))
|
||||
rSocket("rsocket", acceptor = this@magixModule.magixAcceptor(magixFlow))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package ru.mipt.npm.magix.server
|
||||
|
||||
import io.ktor.application.Application
|
||||
import io.ktor.network.selector.ActorSelectorManager
|
||||
import io.ktor.server.application.Application
|
||||
import io.ktor.server.cio.CIO
|
||||
import io.ktor.server.engine.ApplicationEngine
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import io.ktor.util.InternalAPI
|
||||
import io.rsocket.kotlin.core.RSocketServer
|
||||
import io.rsocket.kotlin.transport.ktor.TcpServerTransport
|
||||
import io.rsocket.kotlin.transport.ktor.tcp.TcpServer
|
||||
import io.rsocket.kotlin.transport.ktor.tcp.TcpServerTransport
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import org.slf4j.LoggerFactory
|
||||
@ -20,16 +18,17 @@ import ru.mipt.npm.magix.api.MagixEndpoint.Companion.DEFAULT_MAGIX_RAW_PORT
|
||||
/**
|
||||
* Raw TCP magix server
|
||||
*/
|
||||
@OptIn(InternalAPI::class)
|
||||
public fun CoroutineScope.launchMagixServerRawRSocket(
|
||||
magixFlow: MutableSharedFlow<GenericMagixMessage>,
|
||||
rawSocketPort: Int = DEFAULT_MAGIX_RAW_PORT
|
||||
): Job {
|
||||
val tcpTransport = TcpServerTransport(ActorSelectorManager(Dispatchers.IO), port = rawSocketPort)
|
||||
val rSocketJob = RSocketServer().bind(tcpTransport, magixAcceptor(magixFlow))
|
||||
rawSocketPort: Int = DEFAULT_MAGIX_RAW_PORT,
|
||||
): TcpServer {
|
||||
val tcpTransport = TcpServerTransport(port = rawSocketPort)
|
||||
val rSocketJob: TcpServer = RSocketServer().bindIn(this, tcpTransport, magixAcceptor(magixFlow))
|
||||
|
||||
coroutineContext[Job]?.invokeOnCompletion {
|
||||
rSocketJob.cancel()
|
||||
rSocketJob.handlerJob.cancel()
|
||||
}
|
||||
|
||||
return rSocketJob;
|
||||
}
|
||||
|
||||
@ -42,7 +41,7 @@ public fun CoroutineScope.startMagixServer(
|
||||
buffer: Int = 100,
|
||||
enableRawRSocket: Boolean = true,
|
||||
enableZmq: Boolean = true,
|
||||
applicationConfiguration: Application.(MutableSharedFlow<GenericMagixMessage>) -> Unit = {}
|
||||
applicationConfiguration: Application.(MutableSharedFlow<GenericMagixMessage>) -> Unit = {},
|
||||
): ApplicationEngine {
|
||||
val logger = LoggerFactory.getLogger("magix-server")
|
||||
val magixFlow = MutableSharedFlow<GenericMagixMessage>(
|
||||
|
@ -1,14 +1,13 @@
|
||||
package ru.mipt.npm.magix.server
|
||||
|
||||
import io.ktor.application.ApplicationCall
|
||||
import io.ktor.http.CacheControl
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.response.cacheControl
|
||||
import io.ktor.response.respondBytesWriter
|
||||
import io.ktor.server.application.ApplicationCall
|
||||
import io.ktor.server.response.cacheControl
|
||||
import io.ktor.server.response.respondBytesWriter
|
||||
import io.ktor.utils.io.ByteWriteChannel
|
||||
import io.ktor.utils.io.writeStringUtf8
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
|
||||
/**
|
||||
* The data class representing a SSE Event that will be sent to the client.
|
||||
|
@ -8,10 +8,8 @@ import io.ktor.util.InternalAPI
|
||||
import io.ktor.util.moveToByteArray
|
||||
import io.ktor.utils.io.writeAvailable
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.context.Global
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
|
||||
throwable.printStackTrace()
|
||||
@ -20,7 +18,7 @@ val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
|
||||
@OptIn(InternalAPI::class)
|
||||
fun Context.launchPiDebugServer(port: Int, axes: List<String>): Job = launch(exceptionHandler) {
|
||||
val virtualDevice = PiMotionMasterVirtualDevice(this@launchPiDebugServer, axes)
|
||||
val server = aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().bind(InetSocketAddress("localhost", port))
|
||||
val server = aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().bind("localhost", port)
|
||||
println("Started virtual port server at ${server.localAddress}")
|
||||
|
||||
while (isActive) {
|
||||
|
@ -8,9 +8,9 @@ pluginManagement {
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("https://repo.kotlin.link")
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
}
|
||||
|
||||
plugins {
|
||||
@ -27,8 +27,8 @@ dependencyResolutionManagement {
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("https://repo.kotlin.link")
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
}
|
||||
|
||||
versionCatalogs {
|
||||
@ -45,7 +45,7 @@ include(
|
||||
":controls-server",
|
||||
":controls-opcua",
|
||||
":demo",
|
||||
":demo:car",
|
||||
// ":demo:car",
|
||||
":magix",
|
||||
":magix:magix-api",
|
||||
":magix:magix-server",
|
||||
|
Loading…
Reference in New Issue
Block a user