public class SyncMessageReader extends java.lang.Object implements MessageReader<XMessageHeader,XMessage>
MessageReader. This implementation wraps a InputStream.| Constructor and Description |
|---|
SyncMessageReader(FullReadInputStream inputStream,
Protocol.ProtocolEventHandler protocolEventHandler) |
| Modifier and Type | Method and Description |
|---|---|
int |
getNextNonNoticeMessageType() |
void |
pushMessageListener(MessageListener<XMessage> listener)
Queue a
MessageListener to receive messages delivered asynchronously. |
XMessageHeader |
readHeader()
Read the next message header from server, possibly blocking indefinitely until the message is received.
|
XMessage |
readMessage(java.util.Optional<XMessage> reuse,
int expectedType)
Read message from server into to the given
Message instance or into the new one if not present. |
XMessage |
readMessage(java.util.Optional<XMessage> reuse,
XMessageHeader hdr)
Read message from server into to the given
Message instance or into the new one if not present. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMessageSequence, probeHeader, probeMessage, resetMessageSequence, start, stopAfterNextMessage, undecorate, undecorateAllpublic SyncMessageReader(FullReadInputStream inputStream, Protocol.ProtocolEventHandler protocolEventHandler)
public XMessageHeader readHeader() throws java.io.IOException
MessageReaderreadHeader in interface MessageReader<XMessageHeader,XMessage>MessageHeader of the next messagejava.io.IOException - if an error occurspublic int getNextNonNoticeMessageType()
throws java.io.IOException
java.io.IOExceptionpublic XMessage readMessage(java.util.Optional<XMessage> reuse, XMessageHeader hdr) throws java.io.IOException
MessageReaderMessage instance 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 an IOException during read or parsereadMessage in interface MessageReader<XMessageHeader,XMessage>reuse - Message object to reuse. May be ignored by implementation.hdr - MessageHeader instanceMessage instancejava.io.IOException - if an error occurspublic XMessage readMessage(java.util.Optional<XMessage> reuse, int expectedType) throws java.io.IOException
MessageReaderMessage instance 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).readMessage in interface MessageReader<XMessageHeader,XMessage>reuse - Message object to reuse. May be ignored by implementation.expectedType - Expected type of message.Message instancejava.io.IOException - if an error occurspublic void pushMessageListener(MessageListener<XMessage> listener)
MessageReaderMessageListener to receive messages delivered asynchronously.pushMessageListener in interface MessageReader<XMessageHeader,XMessage>listener - MessageListener