类 StompDecoder
- java.lang.Object
- org.springframework.messaging.simp.stomp.StompDecoder
public class StompDecoder extends Object
Decodes one or more STOMP frames contained in aByteBuffer
.An attempt is made to read all complete STOMP frames from the buffer, which could be zero, one, or more. If there is any left-over content, i.e. an incomplete STOMP frame, at the end the buffer is reset to point to the beginning of the partial content. The caller is then responsible for dealing with that incomplete content by buffering until there is more input available.
- 从以下版本开始:
- 4.0
- 作者:
- Andy Wilkinson, Rossen Stoyanchev
构造器概要
构造器 构造器 说明 StompDecoder()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 List<Message<byte[]>>
decode(ByteBuffer buffer)
Decodes one or more STOMP frames from the givenByteBuffer
into a list ofMessage
s.List<Message<byte[]>>
decode(ByteBuffer buffer, MultiValueMap<String,String> partialMessageHeaders)
Decodes one or more STOMP frames from the givenbuffer
and returns a list ofMessage
s.MessageHeaderInitializer
getHeaderInitializer()
Return the configuredMessageHeaderInitializer
, if any.void
setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure aMessageHeaderInitializer
to apply to the headers ofMessage
s from decoded STOMP frames.protected void
skipLeadingEol(ByteBuffer buffer)
Skip one ore more EOL characters at the start of the given ByteBuffer.
构造器详细资料
StompDecoder
public StompDecoder()
方法详细资料
setHeaderInitializer
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure aMessageHeaderInitializer
to apply to the headers ofMessage
s from decoded STOMP frames.
getHeaderInitializer
public MessageHeaderInitializer getHeaderInitializer()
Return the configuredMessageHeaderInitializer
, if any.
decode
public List<Message<byte[]>> decode(ByteBuffer buffer)
Decodes one or more STOMP frames from the givenByteBuffer
into a list ofMessage
s. If the input buffer contains partial STOMP frame content, or additional content with a partial STOMP frame, the buffer is reset andnull
is returned.- 参数:
buffer
- the buffer to decode the STOMP frame from- 返回:
- the decoded messages, or an empty list if none
- 抛出:
StompConversionException
- raised in case of decoding issues
decode
public List<Message<byte[]>> decode(ByteBuffer buffer, MultiValueMap<String,String> partialMessageHeaders)
Decodes one or more STOMP frames from the givenbuffer
and returns a list ofMessage
s.If the given ByteBuffer contains only partial STOMP frame content and no complete STOMP frames, an empty list is returned, and the buffer is reset to to where it was.
If the buffer contains one ore more STOMP frames, those are returned and the buffer reset to point to the beginning of the unused partial content.
The output partialMessageHeaders map is used to store successfully parsed headers in case of partial content. The caller can then check if a "content-length" header was read, which helps to determine how much more content is needed before the next attempt to decode.
- 参数:
buffer
- the buffer to decode the STOMP frame frompartialMessageHeaders
- an empty output map that will store the last successfully parsed partialMessageHeaders in case of partial message content in cases where the partial buffer ended with a partial STOMP frame- 返回:
- the decoded messages, or an empty list if none
- 抛出:
StompConversionException
- raised in case of decoding issues
skipLeadingEol
protected void skipLeadingEol(ByteBuffer buffer)
Skip one ore more EOL characters at the start of the given ByteBuffer. Those are STOMP heartbeat frames.