d.bellingroth
08/27/2019, 3:02 PMwebSocket("{path...}") {
val url = baseUrl.replaceFirst("http", "ws") + "/" + call.parameters.getAll("path")?.joinToString("/")
val sourceSession = this
<http://client.ws|client.ws>({
url {
takeFrom(url)
parameters.appendAll(call.request.queryParameters)
}
}) {
val targetSession = this
select<Unit> {
targetSession.incoming.onReceive { frame ->
println("Received frame from target ${frame.data.toString(Charset.defaultCharset())}")
sourceSession.send(frame.copy())
}
sourceSession.incoming.onReceive { frame ->
println("Received frame from source ${frame.data.toString(Charset.defaultCharset())}")
targetSession.send(frame.copy())
}
}
}
}