public abstract class NetworkMessage extends Object
Constructor and Description |
---|
NetworkMessage()
Constructor base.
|
NetworkMessage(byte type,
byte clientId)
Create a network message for all clients.
|
NetworkMessage(byte type,
byte clientId,
byte clientDestId)
Create a network message.
|
Modifier and Type | Method and Description |
---|---|
void |
decode(byte type,
byte from,
byte dest,
DataInputStream buffer)
Decode the message from the data.
|
protected abstract void |
decode(DataInputStream buffer)
Decode the message from the data.
|
ByteArrayOutputStream |
encode()
Encode the message.
|
protected abstract void |
encode(ByteArrayOutputStream buffer)
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 static final Charset CHARSET
public NetworkMessage()
public NetworkMessage(byte type, byte clientId)
type
- The message type.clientId
- The client id.public NetworkMessage(byte type, byte clientId, byte clientDestId)
type
- The message type.clientId
- The client id.clientDestId
- The client destination id (-1 if all).protected abstract void encode(ByteArrayOutputStream buffer) throws IOException
buffer
- The current buffer.IOException
- Error on writing.protected abstract void decode(DataInputStream buffer) throws IOException
buffer
- The data reference.IOException
- Error on reading.public final byte getType()
public final byte getClientId()
public final byte getClientDestId()
public final ByteArrayOutputStream encode() throws IOException
IOException
- Error on writing.public final void decode(byte type, byte from, byte dest, DataInputStream buffer) throws IOException
type
- The message type.from
- The client id from.dest
- The client id destination.buffer
- The data reference.IOException
- Error on reading.Copyright © 2017 Byron 3D Games Studio. All rights reserved.