Andrii Iaremenko
02/07/2019, 10:26 AMfun Application.main() {
install(WebSockets){
pingPeriod = Duration.ofSeconds(60)
timeout = Duration.ofSeconds(15)
maxFrameSize = Long.MAX_VALUE
masking = false
}
install(Routing) {
mockPushEvents()
}
}
fun Route.mockPushEvents(){
route(""){
webSocket("/") {
while(true) {
get("/testPushEvents"){
call.respond(someJsonData)
}
val frame = incoming.receive()
when(frame){
is Frame.Text->{
val text = frame.readText()
outgoing.send(Frame.Text("Welcome $text"))
if (text.equals("bye" , ignoreCase = true)){
close(CloseReason(CloseReason.Codes.NORMAL, "Client said Bye"))
}
}
}
}
}
}
}
Thanks for a any help!