link fix in ktor server

This commit is contained in:
InsanusMokrassar 2020-11-02 21:44:12 +06:00
parent 273a7aa9a4
commit 740036e8d9

View File

@ -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")
} }
} }