cah
09/03/2023, 1:08 PMAleksei Tirman [JB]
09/04/2023, 5:21 AMio.ktor:ktor-server-sse
and io.ktor:ktor-client-core
) using the 3.0.0-eap-786
version.cah
09/04/2023, 9:01 AMcah
09/20/2023, 1:19 AMio.ktor:ktor-server-sse:3.0.0-eap-786
and io.ktor.plugin
to run, any advice?
Also on another note we use Resources
for all other endpoints - is it possible to use it with sse
to avoid having to define the path manually?
Thanks againAleksei Tirman [JB]
09/20/2023, 5:45 AMSSEServerContent
class to send SSE events in the handler of a resource route.
embeddedServer(Netty, port = 4444) {
install(SSE)
install(Resources)
routing {
get {
call.respondText(contentType = ContentType.Text.Html) { """
<html>
<body>
<script>
const evtSource = new EventSource("/sse");
evtSource.onmessage = (event) => {
console.log(event.data);
};
</script>
</body>
</html>
""".trimIndent() }
}
get<SseEndpoint> {
call.respond(SSEServerContent(call) {
send(ServerSentEvent("hello"))
})
}
}
}.start(wait = true)
cah
09/20/2023, 9:48 AM