mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-04 23:59:29 +00:00
link fix in ktor server
This commit is contained in:
@@ -2,8 +2,7 @@ package dev.inmo.micro_utils.ktor.server
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.safely
|
import dev.inmo.micro_utils.coroutines.safely
|
||||||
import dev.inmo.micro_utils.ktor.common.*
|
import dev.inmo.micro_utils.ktor.common.*
|
||||||
import io.ktor.http.cio.websocket.DefaultWebSocketSession
|
import io.ktor.http.cio.websocket.*
|
||||||
import io.ktor.http.cio.websocket.close
|
|
||||||
import io.ktor.routing.Route
|
import io.ktor.routing.Route
|
||||||
import io.ktor.websocket.webSocket
|
import io.ktor.websocket.webSocket
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
@@ -23,13 +22,11 @@ fun <T> Route.includeWebsocketHandling(
|
|||||||
converter: (T) -> StandardKtorSerialInputData
|
converter: (T) -> StandardKtorSerialInputData
|
||||||
) {
|
) {
|
||||||
webSocket(suburl) {
|
webSocket(suburl) {
|
||||||
// println("connected")
|
|
||||||
safely {
|
safely {
|
||||||
flow.collect {
|
flow.collect {
|
||||||
send(converter(it))
|
send(converter(it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// println("disconnected")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user