ServerSSESessionWithSerialization
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)))
}
}
To learn more, see the SSE and the SSE specification.
See also
Properties
The received call that originated this session.
Serializer for transforming data object into field data
of ServerSentEvent
.
Functions
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.
Starts a heartbeat for the ServerSSESession.
Sends a ServerSentEvent to the client.
Creates and sends a ServerSentEvent to the client.