ServerSSESession
Represents a server-side Server-Sent Events (SSE) session. An ServerSSESession allows the server to send ServerSentEvent to the client over a single HTTP connection.
Example of usage:
install(SSE)
routing {
sse("/default") {
repeat(100) {
send(ServerSentEvent("event $it"))
}
}
}
Content copied to clipboard
To learn more, see the SSE and the SSE specification.
See also
Inheritors
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
Sends a ServerSentEvent to the client.
open suspend fun send(data: String? = null, event: String? = null, id: String? = null, retry: Long? = null, comments: String? = null)
Creates and sends a ServerSentEvent to the client.