SSE
Server-Sent Events (SSE) support plugin. It is required to be installed first before binding any sse endpoints.
Example of usage:
install(SSE)
routing {
sse("/default") {
repeat(100) {
send(ServerSentEvent("event $it"))
}
}
sse("/serialization", serialize = { typeInfo, it ->
val serializer = Json.serializersModule.serializer(typeInfo.kotlinType!!)
Json.encodeToString(serializer, it)
}) {
send(Customer(0, "Jet", "Brains"))
send(Product(0, listOf(100, 200)))
}
}
Content copied to clipboard
To learn more, see the SSE and the SSE specification.