ResponseBodyEmitter for sending
Server-Sent Events.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | SseEmitter.
A builder for an SSE event. |
| private static class | SseEmitter.
Default implementation of SseEventBuilder. |
| Modifier and Type | Field and Description |
|---|---|
| private static final MediaType | |
| private final Lock | writeLock
Guards access to write operations on the response. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SseEmitter(Long
the timeout value in milliseconds timeout)Create a SseEmitter with a custom timeout value. |
| Modifier and Type | Method and Description |
|---|---|
| public static SseEmitter. | |
| protected void | extendResponse(ServerHttpResponse outputMessage)
Overrides org. Invoked after the response is updated with the status code and headers, if the ResponseBodyEmitter is wrapped in a ResponseEntity, but before the response is committed, i.e. before the response body has been written to. |
| public void | send(Object
the object to write object)Overrides org. Send the object formatted as a single SSE "data" line. |
| public void | send(Object
the object to write object, MediaType a MediaType hint for selecting an HttpMessageConverter mediaType)Overrides org. Send the object formatted as a single SSE "data" line. |
| public void | send(SseEmitter.
a builder for an SSE formatted event. builderSend an SSE event prepared with the given builder. |
| public String | toString()
Overrides org. Returns a string representation of the object. |
| TEXT_PLAIN | back to summary |
|---|---|
| private static final MediaType TEXT_PLAIN | |
| writeLock | back to summary |
|---|---|
| private final Lock writeLock Guards access to write operations on the response. | |
| SseEmitter | back to summary |
|---|---|
| public SseEmitter() Create a new SseEmitter instance. | |
| SseEmitter | back to summary |
|---|---|
| public SseEmitter(Long timeout) Create a SseEmitter with a custom timeout value. By default not set in which case the default configured in the MVC Java Config or the MVC namespace is used, or if that's not set, then the timeout depends on the default of the underlying server.
| |
| event | back to summary |
|---|---|
| public static SseEmitter. | |
| extendResponse | back to summary |
|---|---|
| protected void extendResponse(ServerHttpResponse outputMessage) Overrides org. Doc from org. Invoked after the response is updated with the status code and headers, if the ResponseBodyEmitter is wrapped in a ResponseEntity, but before the response is committed, i.e. before the response body has been written to. The default implementation is empty.
| |
| send | back to summary |
|---|---|
| public void send(Object object) throws IOException Overrides org. Send the object formatted as a single SSE "data" line. It's equivalent to: // static import of SseEmitter.* SseEmitter emitter = new SseEmitter(); emitter.send(event().data(myObject)); Please, see
| |
| send | back to summary |
|---|---|
| public void send(Object object, MediaType mediaType) throws IOException Overrides org. Send the object formatted as a single SSE "data" line. It's equivalent to: // static import of SseEmitter.* SseEmitter emitter = new SseEmitter(); emitter.send(event().data(myObject, MediaType.APPLICATION_JSON)); Please, see
| |
| send | back to summary |
|---|---|
| public void send(SseEmitter. Send an SSE event prepared with the given builder. For example:
// static import of SseEmitter
SseEmitter emitter = new SseEmitter();
emitter.send(event().name("update").id("1").data(myObject));
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Method and Description |
|---|---|
| public Set | |
| public SseEmitter. | |
| public SseEmitter. | |
| public SseEmitter. | |
| public SseEmitter. | |
| public SseEmitter. | |
| public SseEmitter. |
| build | back to summary |
|---|---|
| public Set Return one or more Object-MediaType pairs to write via
| |
| comment | back to summary |
|---|---|
| public SseEmitter. Add an SSE "comment" line. | |
| data | back to summary |
|---|---|
| public SseEmitter. Add an SSE "data" line. | |
| data | back to summary |
|---|---|
| public SseEmitter. Add an SSE "data" line. | |
| id | back to summary |
|---|---|
| public SseEmitter. Add an SSE "id" line. | |
| name | back to summary |
|---|---|
| public SseEmitter. Add an SSE "event" line. | |
| reconnectTime | back to summary |
|---|---|
| public SseEmitter. Add an SSE "retry" line. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Set | |
| private StringBuilder |
| Access | Constructor and Description |
|---|---|
| private |
| dataToSend | back to summary |
|---|---|
| private final Set<ResponseBodyEmitter. | |
| sb | back to summary |
|---|---|
| private StringBuilder sb
| |
| SseEventBuilderImpl | back to summary |
|---|---|
| private SseEventBuilderImpl() | |
| append | back to summary |
|---|---|
| pack-priv SseEmitter. | |
| append | back to summary |
|---|---|
| pack-priv SseEmitter. | |
| build | back to summary |
|---|---|
| public Set Implements org. Doc from org. Return one or more Object-MediaType pairs to write via
| |
| comment | back to summary |
|---|---|
| public SseEmitter. Implements org. Doc from org. Add an SSE "comment" line.
| |
| data | back to summary |
|---|---|
| public SseEmitter. Implements org. Doc from org. Add an SSE "data" line.
| |
| data | back to summary |
|---|---|
| public SseEmitter. Implements org. Doc from org. Add an SSE "data" line.
| |
| id | back to summary |
|---|---|
| public SseEmitter. Implements org. Doc from org. Add an SSE "id" line.
| |
| name | back to summary |
|---|---|
| public SseEmitter. Implements org. Doc from org. Add an SSE "event" line.
| |
| reconnectTime | back to summary |
|---|---|
| public SseEmitter. Implements org. Doc from org. Add an SSE "retry" line.
| |
| saveAppendedText | back to summary |
|---|---|
| private void saveAppendedText() | |