类 BufferingStompDecoder
- java.lang.Object
- org.springframework.messaging.simp.stomp.BufferingStompDecoder
public class BufferingStompDecoder extends Object
An extension ofStompDecoder
that buffers content remaining in the input ByteBuffer after the parent class has read all (complete) STOMP frames from it. The remaining content represents an incomplete STOMP frame. When called repeatedly with additional data, the decode method returns one or more messages or, if there is not enough data still, continues to buffer.A single instance of this decoder can be invoked repeatedly to read all messages from a single stream (e.g. WebSocket session) as long as decoding does not fail. If there is an exception, StompDecoder instance should not be used any more as its internal state is not guaranteed to be consistent. It is expected that the underlying session is closed at that point.
- 从以下版本开始:
- 4.0.3
- 作者:
- Rossen Stoyanchev
- 另请参阅:
StompDecoder
构造器概要
构造器 构造器 说明 BufferingStompDecoder(StompDecoder stompDecoder, int bufferSizeLimit)
Create a newBufferingStompDecoder
wrapping the givenStompDecoder
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 List<Message<byte[]>>
decode(ByteBuffer newBuffer)
Decodes one or more STOMP frames from the givenByteBuffer
into a list ofMessage
s.int
getBufferSize()
Calculate the current buffer size.int
getBufferSizeLimit()
Return the configured buffer size limit.Integer
getExpectedContentLength()
Get the expected content length of the currently buffered, incomplete STOMP frame.StompDecoder
getStompDecoder()
Return the wrappedStompDecoder
.
构造器详细资料
BufferingStompDecoder
public BufferingStompDecoder(StompDecoder stompDecoder, int bufferSizeLimit)
Create a newBufferingStompDecoder
wrapping the givenStompDecoder
.- 参数:
stompDecoder
- the target decoder to wrapbufferSizeLimit
- the buffer size limit
方法详细资料
getStompDecoder
public final StompDecoder getStompDecoder()
Return the wrappedStompDecoder
.
getBufferSizeLimit
public final int getBufferSizeLimit()
Return the configured buffer size limit.
decode
public List<Message<byte[]>> decode(ByteBuffer newBuffer)
Decodes one or more STOMP frames from the givenByteBuffer
into a list ofMessage
s.If there was enough data to parse a "content-length" header, then the value is used to determine how much more data is needed before a new attempt to decode is made.
If there was not enough data to parse the "content-length", or if there is "content-length" header, every subsequent call to decode attempts to parse again with all available data. Therefore the presence of a "content-length" header helps to optimize the decoding of large messages.
- 参数:
newBuffer
- a buffer containing new data to decode- 返回:
- decoded messages or an empty list
- 抛出:
StompConversionException
- raised in case of decoding issues
getBufferSize
public int getBufferSize()
Calculate the current buffer size.
getExpectedContentLength
public Integer getExpectedContentLength()
Get the expected content length of the currently buffered, incomplete STOMP frame.