类 ServerSentEventHttpMessageReader
java.lang.Object
cn.taketoday.http.codec.ServerSentEventHttpMessageReader
- 所有已实现的接口:
HttpMessageReader<Object>
Reader that supports a stream of
ServerSentEvents and also plain
Objects which is the same as an ServerSentEvent with data only.- 从以下版本开始:
- 4.0
- 作者:
- Sebastien Deleuze, Rossen Stoyanchev
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private final cn.taketoday.core.codec.Decoder<?>private final cn.taketoday.core.codec.StringDecoderprivate static final cn.taketoday.core.ResolvableType -
构造器概要
构造器构造器说明Constructor without aDecoder.ServerSentEventHttpMessageReader(cn.taketoday.core.codec.Decoder<?> decoder) Constructor with JSONDecoderfor decoding to Objects. -
方法概要
修饰符和类型方法说明private ObjectbuildEvent(List<String> lines, cn.taketoday.core.ResolvableType valueType, boolean shouldWrap, Map<String, Object> hints) booleanWhether the given object type is supported by this reader.private ObjectdecodeData(StringBuilder data, cn.taketoday.core.ResolvableType dataType, Map<String, Object> hints) cn.taketoday.core.codec.Decoder<?>Return the configuredDecoder.intReturn theconfiguredbyte count limit.Return the list of media types supported by this reader.private booleanisServerSentEvent(cn.taketoday.core.ResolvableType elementType) reactor.core.publisher.Flux<Object>read(cn.taketoday.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) Read from the input message and decode to a stream of objects.reactor.core.publisher.Mono<Object>readMono(cn.taketoday.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) Read from the input message and decode to a single object.voidsetMaxInMemorySize(int byteCount) Configure a limit on the maximum number of bytes per SSE event which are buffered before the event is parsed.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.http.codec.HttpMessageReader
getReadableMediaTypes, read, readMono
-
字段详细资料
-
STRING_TYPE
private static final cn.taketoday.core.ResolvableType STRING_TYPE -
decoder
@Nullable private final cn.taketoday.core.codec.Decoder<?> decoder -
lineDecoder
private final cn.taketoday.core.codec.StringDecoder lineDecoder
-
-
构造器详细资料
-
ServerSentEventHttpMessageReader
public ServerSentEventHttpMessageReader()Constructor without aDecoder. In this mode onlyStringis supported as the data of an event. -
ServerSentEventHttpMessageReader
public ServerSentEventHttpMessageReader(@Nullable cn.taketoday.core.codec.Decoder<?> decoder) Constructor with JSONDecoderfor decoding to Objects. Support for decoding toStringevent data is built-in.
-
-
方法详细资料
-
getDecoder
@Nullable public cn.taketoday.core.codec.Decoder<?> getDecoder()Return the configuredDecoder. -
setMaxInMemorySize
public void setMaxInMemorySize(int byteCount) Configure a limit on the maximum number of bytes per SSE event which are buffered before the event is parsed.Note that the
data decoder, if provided, must also be customized accordingly to raise the limit if necessary in order to be able to parse the data portion of the event.By default this is set to 256K.
- 参数:
byteCount- the max number of bytes to buffer, or -1 for unlimited
-
getMaxInMemorySize
public int getMaxInMemorySize()Return theconfiguredbyte count limit. -
getReadableMediaTypes
从接口复制的说明:HttpMessageReaderReturn the list of media types supported by this reader. The list may not apply to every possible target element type and calls to this method should typically be guarded viacanWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, useHttpMessageReader.getReadableMediaTypes(ResolvableType)for a more precise list.- 指定者:
getReadableMediaTypes在接口中HttpMessageReader<Object>- 返回:
- the general list of supported media types
-
canRead
从接口复制的说明:HttpMessageReaderWhether the given object type is supported by this reader.- 指定者:
canRead在接口中HttpMessageReader<Object>- 参数:
elementType- the type of object to checkmediaType- the media type for the read (possiblynull)- 返回:
trueif readable,falseotherwise
-
isServerSentEvent
private boolean isServerSentEvent(cn.taketoday.core.ResolvableType elementType) -
read
public reactor.core.publisher.Flux<Object> read(cn.taketoday.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) 从接口复制的说明:HttpMessageReaderRead from the input message and decode to a stream of objects.- 指定者:
read在接口中HttpMessageReader<Object>- 参数:
elementType- the type of objects in the stream which must have been previously checked viaHttpMessageReader.canRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- 返回:
- the decoded stream of elements
-
buildEvent
-
decodeData
@Nullable private Object decodeData(StringBuilder data, cn.taketoday.core.ResolvableType dataType, Map<String, Object> hints) -
readMono
public reactor.core.publisher.Mono<Object> readMono(cn.taketoday.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) 从接口复制的说明:HttpMessageReaderRead from the input message and decode to a single object.- 指定者:
readMono在接口中HttpMessageReader<Object>- 参数:
elementType- the type of objects in the stream which must have been previously checked viaHttpMessageReader.canRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- 返回:
- the decoded object
-