public class SimplePacketReader extends java.lang.Object implements MessageReader<NativePacketHeader,NativePacketPayload>
MessageReader which handles the receiving of logical MySQL packets from the provided socket input stream.
Multi-packets are handled outside of this reader.| Modifier and Type | Field and Description |
|---|---|
protected RuntimeProperty<java.lang.Integer> |
maxAllowedPacket |
protected SocketConnection |
socketConnection |
| Constructor and Description |
|---|
SimplePacketReader(SocketConnection socketConnection,
RuntimeProperty<java.lang.Integer> maxAllowedPacket) |
| Modifier and Type | Method and Description |
|---|---|
byte |
getMessageSequence()
Get last message sequence number, as it was stored by
MessageReader.readHeader(). |
NativePacketHeader |
readHeader()
Read the next message header from server, possibly blocking indefinitely until the message is received.
|
NativePacketPayload |
readMessage(java.util.Optional<NativePacketPayload> reuse,
NativePacketHeader header)
Read message from server into to the given
Message instance or into the new one if not present. |
void |
resetMessageSequence()
Set stored message sequence number to 0.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpushMessageListener, readMessage, start, stopAfterNextMessage, undecorate, undecorateAllprotected SocketConnection socketConnection
protected RuntimeProperty<java.lang.Integer> maxAllowedPacket
public SimplePacketReader(SocketConnection socketConnection, RuntimeProperty<java.lang.Integer> maxAllowedPacket)
public NativePacketHeader readHeader() throws java.io.IOException
MessageReaderreadHeader in interface MessageReader<NativePacketHeader,NativePacketPayload>MessageHeader of the next messagejava.io.IOException - if an error occurspublic NativePacketPayload readMessage(java.util.Optional<NativePacketPayload> reuse, NativePacketHeader header) 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<NativePacketHeader,NativePacketPayload>reuse - Message object to reuse. May be ignored by implementation.header - MessageHeader instanceMessage instancejava.io.IOException - if an error occurspublic byte getMessageSequence()
MessageReaderMessageReader.readHeader().getMessageSequence in interface MessageReader<NativePacketHeader,NativePacketPayload>public void resetMessageSequence()
MessageReaderresetMessageSequence in interface MessageReader<NativePacketHeader,NativePacketPayload>