public abstract class NetworkMessage
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.nio.charset.Charset |
CHARSET
Charset.
|
Constructor and Description |
---|
NetworkMessage()
Constructor.
|
NetworkMessage(java.lang.Enum<?> type,
byte clientId)
Constructor.
|
NetworkMessage(java.lang.Enum<?> type,
byte clientId,
byte clientDestId)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
decode(byte type,
byte from,
byte dest,
java.io.DataInputStream buffer)
Decode the message from the data.
|
java.io.ByteArrayOutputStream |
encode()
Encode the message.
|
byte |
getClientDestId()
Get the destination of this message.
|
byte |
getClientId()
Get the owner if of this message.
|
byte |
getType()
Get the message type.
|
public NetworkMessage()
public NetworkMessage(java.lang.Enum<?> type, byte clientId)
type
- The message type.clientId
- The client id.public NetworkMessage(java.lang.Enum<?> type, byte clientId, byte clientDestId)
type
- The message type.clientId
- The client id.clientDestId
- The client destination id (-1 if all).public final byte getType()
public final byte getClientId()
public final byte getClientDestId()
public final java.io.ByteArrayOutputStream encode() throws java.io.IOException
java.io.IOException
- Error on writing.public final void decode(byte type, byte from, byte dest, java.io.DataInputStream buffer) throws java.io.IOException
type
- The message type.from
- The client id from.dest
- The client id destination.buffer
- The data reference.java.io.IOException
- Error on reading.