M
- The message entity element enum.public abstract class NetworkMessageEntity<M extends Enum<M>> extends NetworkMessage
CHARSET
Constructor and Description |
---|
NetworkMessageEntity()
Constructor (used in decoding case).
|
NetworkMessageEntity(Enum<?> type,
byte clientId)
Constructor (used for the client case).
|
NetworkMessageEntity(Enum<?> type,
short entityId)
Constructor (used to identify an entity from the server).
|
NetworkMessageEntity(Enum<?> type,
short entityId,
byte destId)
Constructor (used to identify an entity from the server).
|
Modifier and Type | Method and Description |
---|---|
void |
addAction(M element,
boolean value)
Add an action.
|
void |
addAction(M element,
byte value)
Add an action.
|
void |
addAction(M element,
char value)
Add an action.
|
void |
addAction(M element,
double value)
Add an action.
|
void |
addAction(M element,
int value)
Add an action.
|
void |
addAction(M element,
short value)
Add an action.
|
protected void |
decode(DataInputStream buffer)
Read the first byte to retrieve the total number of key and call
for each
key . |
protected abstract void |
decode(DataInputStream buffer,
int i)
Decode function for the current key number.
|
protected void |
encode(ByteArrayOutputStream buffer)
Retrieve the keys, store its total number in the buffer, and call
for
each key . |
protected abstract void |
encode(ByteArrayOutputStream buffer,
M key)
Encode function for the current key.
|
boolean |
getActionBoolean(M element)
Get the action value.
|
byte |
getActionByte(M element)
Get the action value.
|
char |
getActionChar(M element)
Get the action value.
|
double |
getActionDouble(M element)
Get the action value.
|
int |
getActionInteger(M element)
Get the action value.
|
short |
getActionShort(M element)
Get the action value.
|
short |
getEntityId()
Get the entity id (-1 if none).
|
boolean |
hasAction(M element)
Check if the action is contained.
|
decode, encode, getClientDestId, getClientId, getType
public NetworkMessageEntity()
public NetworkMessageEntity(Enum<?> type, byte clientId)
type
- The message type.clientId
- The client id.public NetworkMessageEntity(Enum<?> type, short entityId)
type
- The message type.entityId
- The entity id.public NetworkMessageEntity(Enum<?> type, short entityId, byte destId)
type
- The message type.entityId
- The entity id.destId
- The client destination.protected abstract void encode(ByteArrayOutputStream buffer, M key) throws IOException
buffer
- The current buffer to write.key
- The current key.IOException
- Exception in case of error.protected abstract void decode(DataInputStream buffer, int i) throws IOException
buffer
- The current buffer to read.i
- The current key number.IOException
- Exception in case of error.public void addAction(M element, boolean value)
element
- The action type.value
- The action value.public void addAction(M element, char value)
element
- The action type.value
- The action value.public void addAction(M element, byte value)
element
- The action type.value
- The action value.public void addAction(M element, short value)
element
- The action type.value
- The action value.public void addAction(M element, int value)
element
- The action type.value
- The action value.public void addAction(M element, double value)
element
- The action type.value
- The action value.public boolean getActionBoolean(M element)
element
- The action element.public byte getActionByte(M element)
element
- The action element.public char getActionChar(M element)
element
- The action element.public short getActionShort(M element)
element
- The action element.public int getActionInteger(M element)
element
- The action element.public double getActionDouble(M element)
element
- The action element.public boolean hasAction(M element)
element
- The action to check.true
if action is contained, false
else.public short getEntityId()
protected void encode(ByteArrayOutputStream buffer) throws IOException
for
each key
.encode
in class NetworkMessage
buffer
- The current buffer to write.IOException
- Exception in case of error.protected void decode(DataInputStream buffer) throws IOException
for each
key
.decode
in class NetworkMessage
buffer
- The current buffer to read.IOException
- Exception in case of error.Copyright © 2014 Byron 3D Games Studio. All rights reserved.