|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnaga.packetwriter.RawPacketWriter
public class RawPacketWriter
Writes a byte packet to the stream without doing any changes to it.
This is the commonly case when one wants to output text or similarly delimited data.
Constructor Summary | |
---|---|
RawPacketWriter()
Creates a new writer. |
Method Summary | |
---|---|
java.nio.ByteBuffer |
getBuffer()
The current byte buffer to write to the socket. |
boolean |
isEmpty()
Determines if the packet writer has more data to write. |
void |
setPacket(byte[] bytes)
Set the next packet to write. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RawPacketWriter()
Method Detail |
---|
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |