naga.packetwriter
public class RawPacketWriter extends java.lang.Object implements PacketWriter
This is the commonly case when one wants to output text or similarly delimited data.
Constructor and Description |
---|
RawPacketWriter()
Creates a new writer.
|
public void setPacket(byte[] bytes)
PacketWriter
setPacket
in interface PacketWriter
bytes
- an array of bytes representing the next packet.public java.nio.ByteBuffer getBuffer()
PacketWriter
Note that the socket does no rewinding or similar of the buffer,
the only way it interacts with the buffer is by calling
SocketChannel.write(ByteBuffer)
, so the implementing
class needs to make sure that the buffer is in the right state.
This code will not be called unless PacketWriter.isEmpty()
returns false.
getBuffer
in interface PacketWriter
public boolean isEmpty()
PacketWriter
Classes will never invoke PacketWriter.setPacket(byte[])
unless
isEmpty
returns true.
isEmpty
in interface PacketWriter