类 SseEmitter
java.lang.Object
cn.taketoday.web.handler.method.ResponseBodyEmitter
cn.taketoday.web.handler.method.SseEmitter
A specialization of
ResponseBodyEmitter for sending
Server-Sent Events.- 从以下版本开始:
- 4.0 2022/4/8 23:55
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Sam Brannen, Harry Yang
-
嵌套类概要
嵌套类修饰符和类型类说明static interfaceA builder for an SSE event.private static classDefault implementation of SseEventBuilder.从类继承的嵌套类/接口 cn.taketoday.web.handler.method.ResponseBodyEmitter
ResponseBodyEmitter.DataWithMediaType, ResponseBodyEmitter.Handler -
字段概要
字段修饰符和类型字段说明private static final MediaTypeprivate final ReentrantLockGuards access to write operations on the response. -
构造器概要
构造器构造器说明Create a new SseEmitter instance.SseEmitter(Long timeout) Create a SseEmitter with a custom timeout value. -
方法概要
修饰符和类型方法说明static SseEmitter.SseEventBuilderevent()protected voidextendResponse(RequestContext outputMessage) 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.voidsend(SseEmitter.SseEventBuilder builder) Send an SSE event prepared with the given builder.voidSend the object formatted as a single SSE "data" line.voidSend the object formatted as a single SSE "data" line.toString()从类继承的方法 cn.taketoday.web.handler.method.ResponseBodyEmitter
complete, completeWithError, getTimeout, initialize, initializeWithError, onCompletion, onError, onTimeout, send
-
字段详细资料
-
TEXT_PLAIN
-
writeLock
Guards access to write operations on the response.
-
-
构造器详细资料
-
SseEmitter
public SseEmitter()Create a new SseEmitter instance. -
SseEmitter
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.
- 参数:
timeout- the timeout value in milliseconds
-
-
方法详细资料
-
extendResponse
从类复制的说明:ResponseBodyEmitterInvoked 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.
- 覆盖:
extendResponse在类中ResponseBodyEmitter
-
send
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
parent Javadocfor important notes on exception handling.- 覆盖:
send在类中ResponseBodyEmitter- 参数:
object- the object to write- 抛出:
IOException- raised when an I/O error occursIllegalStateException- wraps any other errors
-
send
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
parent Javadocfor important notes on exception handling.- 覆盖:
send在类中ResponseBodyEmitter- 参数:
object- the object to writemediaType- a MediaType hint for selecting an HttpMessageConverter- 抛出:
IOException- raised when an I/O error occurs
-
send
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));- 参数:
builder- a builder for an SSE formatted event.- 抛出:
IOException- raised when an I/O error occurs
-
toString
- 覆盖:
toString在类中ResponseBodyEmitter
-
event
-