类 ServerSentEventHttpMessageWriter

java.lang.Object
cn.taketoday.http.codec.ServerSentEventHttpMessageWriter
所有已实现的接口:
HttpMessageWriter<Object>

public class ServerSentEventHttpMessageWriter extends Object implements HttpMessageWriter<Object>
HttpMessageWriter for "text/event-stream" responses.
从以下版本开始:
4.0
作者:
Sebastien Deleuze, Arjen Poutsma, Rossen Stoyanchev
  • 字段详细资料

    • logger

      private static final cn.taketoday.logging.Logger logger
    • DEFAULT_MEDIA_TYPE

      private static final MediaType DEFAULT_MEDIA_TYPE
    • WRITABLE_MEDIA_TYPES

      private static final List<MediaType> WRITABLE_MEDIA_TYPES
    • encoder

      @Nullable private final cn.taketoday.core.codec.Encoder<?> encoder
  • 构造器详细资料

    • ServerSentEventHttpMessageWriter

      public ServerSentEventHttpMessageWriter()
      Constructor without an Encoder. In this mode only String is supported for event data to be encoded.
    • ServerSentEventHttpMessageWriter

      public ServerSentEventHttpMessageWriter(@Nullable cn.taketoday.core.codec.Encoder<?> encoder)
      Constructor with JSON Encoder for encoding objects. Support for String event data is built-in.
      参数:
      encoder - the Encoder to use (may be null)
  • 方法详细资料

    • getEncoder

      @Nullable public cn.taketoday.core.codec.Encoder<?> getEncoder()
      Return the configured Encoder, if any.
    • getWritableMediaTypes

      public List<MediaType> getWritableMediaTypes()
      从接口复制的说明: HttpMessageWriter
      Return the list of media types supported by this Writer. The list may not apply to every possible target element type and calls to this method should typically be guarded via canWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, use HttpMessageWriter.getWritableMediaTypes(ResolvableType) for a more precise list.
      指定者:
      getWritableMediaTypes 在接口中 HttpMessageWriter<Object>
      返回:
      the general list of supported media types
    • canWrite

      public boolean canWrite(cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType)
      从接口复制的说明: HttpMessageWriter
      Whether the given object type is supported by this writer.
      指定者:
      canWrite 在接口中 HttpMessageWriter<Object>
      参数:
      elementType - the type of object to check
      mediaType - the media type for the write (possibly null)
      返回:
      true if writable, false otherwise
    • write

      public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<?> input, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
      从接口复制的说明: HttpMessageWriter
      Write an given stream of object to the output message.
      指定者:
      write 在接口中 HttpMessageWriter<Object>
      参数:
      input - the objects to write
      elementType - the type of objects in the stream which must have been previously checked via HttpMessageWriter.canWrite(ResolvableType, MediaType)
      mediaType - the content type for the write (possibly null to indicate that the default content type of the writer must be used)
      message - the message to write to
      hints - additional information about how to encode and write
      返回:
      indicates completion or error
    • encode

      private reactor.core.publisher.Flux<org.reactivestreams.Publisher<cn.taketoday.core.io.buffer.DataBuffer>> encode(org.reactivestreams.Publisher<?> input, cn.taketoday.core.ResolvableType elementType, MediaType mediaType, cn.taketoday.core.io.buffer.DataBufferFactory factory, Map<String,Object> hints)
    • encodeEvent

      private <T> reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer> encodeEvent(StringBuilder eventContent, T data, cn.taketoday.core.ResolvableType dataType, MediaType mediaType, cn.taketoday.core.io.buffer.DataBufferFactory factory, Map<String,Object> hints)
    • writeField

      private void writeField(String fieldName, Object fieldValue, StringBuilder sb)
    • encodeText

      private cn.taketoday.core.io.buffer.DataBuffer encodeText(CharSequence text, MediaType mediaType, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory)
    • write

      public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<?> input, cn.taketoday.core.ResolvableType actualType, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
      从接口复制的说明: HttpMessageWriter
      Server-side only alternative to HttpMessageWriter.write(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map) with additional context available.
      指定者:
      write 在接口中 HttpMessageWriter<Object>
      actualType - the actual return type of the method that returned the value; for annotated controllers, the Parameter can be accessed via ResolvableType.getSource().
      elementType - the type of Objects in the input stream
      mediaType - the content type to use (possibly null indicating the default content type of the writer should be used)
      request - the current request
      response - the current response
      返回:
      a Mono that indicates completion of writing or error
    • getEncodeHints

      private Map<String,Object> getEncodeHints(cn.taketoday.core.ResolvableType actualType, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)