Server SSESession With Serialization
Represents a server-side Server-Sent Events (SSE) session with serialization support. An ServerSSESessionWithSerialization allows the server to send ServerSentEvent to the client over a single HTTP connection.
Example of usage:
install(SSE)
routing {
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.
See also
Properties
Functions
Link copied to clipboard
Closes the ServerSSESession, terminating the connection with the client. Once this method is called, the SSE session is closed and no further events can be sent. You don't need to call this method as it is called automatically when all the send operations are completed.
Link copied to clipboard
Starts a heartbeat for the ServerSSESession.
Link copied to clipboard
Link copied to clipboard