@PrivateApi public class PacketIOHelper extends Object
PacketIOHelper
is stateful because it tracks where the packet reading from ByteBuffer or writing to ByteBuffer.
A PacketIOHelper
instance should only be used for reading, or only be used for writing. So if you need to read and
write at the same time, you need to have 2 instances.
A PacketIOHelper
is designed to be reused.Constructor and Description |
---|
PacketIOHelper() |
Modifier and Type | Method and Description |
---|---|
Packet |
readFrom(ByteBuffer src)
Reads the packet data from the supplied
ByteBuffer . |
boolean |
writeTo(Packet packet,
ByteBuffer dst)
Writes the packet data to the supplied
ByteBuffer , up to the buffer's limit. |
public boolean writeTo(Packet packet, ByteBuffer dst)
ByteBuffer
, up to the buffer's limit. If it returns false
,
it should be called again to write the remaining data.dst
- the destination byte buffertrue
if all the packet's data is now written out; false
otherwise.public Packet readFrom(ByteBuffer src)
ByteBuffer
. The buffer may not contain the complete packet.
If this method returns false
, it should be called again to read more packet data.src
- the source byte buffernull
otherwise.Copyright © 2018 Hazelcast, Inc.. All rights reserved.