接口 MessageReader<H extends MessageHeader,M extends Message>
-
- 所有已知实现类:
DebugBufferingPacketReader,MultiPacketReader,SimplePacketReader,SyncMessageReader,TimeTrackingPacketReader,TracingPacketReader
public interface MessageReader<H extends MessageHeader,M extends Message>
-
-
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 default bytegetMessageSequence()Get last message sequence number, as it was stored byreadHeader().default HprobeHeader()Read the next message header from server, possibly blocking indefinitely until the message is received, and cache it so that the nextreadHeader()return the same header.default MprobeMessage(Optional<M> reuse, H header)Read message from server into to the givenMessageinstance or into the new one if not present and cache it so that the nextreadMessage(Optional, MessageHeader)return the same message.default voidpushMessageListener(MessageListener<M> l)Queue aMessageListenerto receive messages delivered asynchronously.HreadHeader()Read the next message header from server, possibly blocking indefinitely until the message is received.default MreadMessage(Optional<M> reuse, int expectedType)Read message from server into to the givenMessageinstance or into the new one if not present.MreadMessage(Optional<M> reuse, H header)Read message from server into to the givenMessageinstance or into the new one if not present.default voidresetMessageSequence()Set stored message sequence number to 0.default voidstart()Start reading messages reader from the provided channel.default voidstopAfterNextMessage()Signal to the reader that it should stop reading messages after reading the next message.default MessageReader<H,M>undecorate()Return the previous MessageReader instance from the decorators chain or the current MessageReader if it is the first entry in a chain.default MessageReader<H,M>undecorateAll()Return a MessageReader instance free of decorators.
-
-
-
方法详细资料
-
readHeader
H readHeader() throws IOException
Read the next message header from server, possibly blocking indefinitely until the message is received.- 返回:
MessageHeaderof the next message- 抛出:
IOException- if an error occurs
-
probeHeader
default H probeHeader() throws IOException
Read the next message header from server, possibly blocking indefinitely until the message is received, and cache it so that the nextreadHeader()return the same header.- 返回:
MessageHeaderof the next message- 抛出:
IOException- if an error occurs
-
readMessage
M readMessage(Optional<M> reuse, H header) throws IOException
Read message from server into to the givenMessageinstance or into the new one if not present. For asynchronous channel it synchronously reads the next message in the stream, blocking until the message is read fully. Could throw CJCommunicationsException wrapping anIOExceptionduring read or parse- 参数:
reuse-Messageobject to reuse. May be ignored by implementation.header-MessageHeaderinstance- 返回:
Messageinstance- 抛出:
IOException- if an error occurs
-
probeMessage
default M probeMessage(Optional<M> reuse, H header) throws IOException
Read message from server into to the givenMessageinstance or into the new one if not present and cache it so that the nextreadMessage(Optional, MessageHeader)return the same message. For asynchronous channel it synchronously reads the next message in the stream, blocking until the message is read fully. Could throw CJCommunicationsException wrapping anIOExceptionduring read or parse- 参数:
reuse-Messageobject to reuse. May be ignored by implementation.header-MessageHeaderinstance- 返回:
Messageinstance- 抛出:
IOException- if an error occurs
-
readMessage
default M readMessage(Optional<M> reuse, int expectedType) throws IOException
Read message from server into to the givenMessageinstance or into the new one if not present. For asynchronous channel it synchronously reads the next message in the stream, blocking until the message is read fully. Could throw WrongArgumentException if the expected message type is not the next message (exception will be thrown in *caller* context).- 参数:
reuse-Messageobject to reuse. May be ignored by implementation.expectedType- Expected type of message.- 返回:
Messageinstance- 抛出:
IOException- if an error occurs
-
pushMessageListener
default void pushMessageListener(MessageListener<M> l)
Queue aMessageListenerto receive messages delivered asynchronously.- 参数:
l-MessageListener
-
getMessageSequence
default byte getMessageSequence()
Get last message sequence number, as it was stored byreadHeader().- 返回:
- number
-
resetMessageSequence
default void resetMessageSequence()
Set stored message sequence number to 0.
-
undecorateAll
default MessageReader<H,M> undecorateAll()
Return a MessageReader instance free of decorators.- 返回:
MessageReader
-
undecorate
default MessageReader<H,M> undecorate()
Return the previous MessageReader instance from the decorators chain or the current MessageReader if it is the first entry in a chain.- 返回:
MessageReader
-
start
default void start()
Start reading messages reader from the provided channel.
-
stopAfterNextMessage
default void stopAfterNextMessage()
Signal to the reader that it should stop reading messages after reading the next message.
-
-