kafka -> websockets working!!
This commit is contained in:
parent
55bea4aed4
commit
7813756c69
12 changed files with 265 additions and 142 deletions
|
|
@ -7,40 +7,35 @@ import org.http4k.websocket.WsMessage
|
|||
|
||||
fun main() {
|
||||
|
||||
// val client = WebsocketClient.blocking(
|
||||
// uri = Uri.of("ws://localhost:8095/ws"),
|
||||
//// autoReconnection = true,
|
||||
//// timeout = Duration.ofSeconds(30)
|
||||
// )
|
||||
//// client.send(WsMessage("server sent on connection"))
|
||||
//
|
||||
// client.received()
|
||||
// .take(100)
|
||||
// .forEachIndexed { index, wsMessage ->
|
||||
// println("[$index] ${wsMessage.bodyString()}")
|
||||
// }
|
||||
|
||||
|
||||
val nonBlockingClient = WebsocketClient.nonBlocking(
|
||||
uri = Uri.of("ws://localhost:9292/lua-objects"),
|
||||
onError = { it.printStackTrace() },
|
||||
onConnect = { ws ->
|
||||
println("onConnect, ws.upgradeRequest ${ws.upgradeRequest}")
|
||||
// ws.send(WsMessage("client sent on connection"))
|
||||
}
|
||||
val client = WebsocketClient.blocking(
|
||||
uri = Uri.of("ws://localhost:9073/ws"),
|
||||
// autoReconnection = true,
|
||||
// timeout = Duration.ofSeconds(30)
|
||||
)
|
||||
// client.send(WsMessage("server sent on connection"))
|
||||
|
||||
nonBlockingClient.onMessage { msg -> print(msg.bodyString()) }
|
||||
client.received()
|
||||
.take(100)
|
||||
.forEachIndexed { index, wsMessage ->
|
||||
println("[$index] ${wsMessage.bodyString()}")
|
||||
}
|
||||
|
||||
|
||||
nonBlockingClient.onClose {
|
||||
println("non-blocking client closing")
|
||||
}
|
||||
|
||||
|
||||
nonBlockingClient.onError { it.printStackTrace() }
|
||||
|
||||
|
||||
Thread.sleep(Duration.ofMinutes(1).toMillis())
|
||||
// val nonBlockingClient = WebsocketClient.nonBlocking(
|
||||
// uri = Uri.of("ws://localhost:9097/lua-objects"),
|
||||
// onError = { it.printStackTrace() },
|
||||
// onConnect = { ws ->
|
||||
// println("onConnect, ws.upgradeRequest ${ws.upgradeRequest}")
|
||||
//// ws.send(WsMessage("client sent on connection"))
|
||||
// }
|
||||
// )
|
||||
//
|
||||
// nonBlockingClient.onMessage { msg -> print(msg.bodyString()) }
|
||||
// nonBlockingClient.onClose {
|
||||
// println("non-blocking client closing")
|
||||
// }
|
||||
//// nonBlockingClient.onError { it.printStackTrace() }
|
||||
//
|
||||
// Thread.sleep(Duration.ofMinutes(1).toMillis())
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue