#include <messagepacket.h>
Public Methods | |
MessagePacket () | |
Creates an empty writable MessagePacket. | |
MessagePacket (UDPpacket &src) | |
Creates a readable MessagePacket filled with the contents of the UDPpacket. | |
void | append (string newMsg) |
Appends a message to the packet. More... | |
void | append (const MessagePacket &msgPacket) |
Appends two MessagePacket. More... | |
void | clear () |
Empties the message packet. More... | |
string | next () |
Returns the next message. More... | |
bool | remainingMessages () const |
Tells if there are still some messages in the packet. More... | |
bool | writable () const |
Indicates if we can write to this MessagePacket. More... | |
bool | readable () const |
Indicates if we can read from this MessagePacket. More... | |
int | size () const |
Returns the size in bytes of the message data. More... | |
int | packetSize () const |
Returns the size in bytes of the whole message packet. More... | |
const char * | getRawData () const |
Returns the string containing the whole bunch of data. More... | |
void | print () const |
Useful for debugging. | |
void | setClientIndex (Sint32 index) |
Sets the client index of the packet. More... | |
Sint32 | getClientIndex () const |
Gets the client index of the packet sender. More... | |
Private Attributes | |
string | msgList |
Messages are appended to the end of the string, separated by the magic string defined in SEPARATOR, which I consider is pretty unlikely to appear later during the game in a regular message. | |
bool | _writable |
Indicates whether we can or cannot write to this MessagePacket. | |
unsigned | pointer |
When reading, indicates the position of the next message in the list. | |
Static Private Attributes | |
const string | SEPARATOR = string("$}") |
String that separates the different messages in the packet. | |
const int | HEADER_LENGTH = sizeof(Uint32) + sizeof(Sint32) |
Length of the information before the actual data. |
These are the messages to be sent over the network The network module doesn't understand about the format of the message string, just delivers it
|
Appends two MessagePacket. Appends another message packet to the end of this packet, perhaps making some optimizations in order to reduce information redundancy. Throws an string as the result of an exception if "this" is in read mode.
|
|
Appends a message to the packet. Appends another message to the end of the packet. Throws an string as the result of an exception if "this" is in read mode.
|
|
Empties the message packet. Empties the message packet. Throws an string as the result of an exception if "this" is in read mode. |
|
Gets the client index of the packet sender. Gets the client index of the packet sender, to facilitate its management in the server.
|
|
Returns the string containing the whole bunch of data. This is supposed to be used by the NetManager.
|
|
Returns the next message. Returns the next message to be read, and advances the pointer. Throws an exception if there are no more messages left.
|
|
Returns the size in bytes of the whole message packet.
|
|
Indicates if we can read from this MessagePacket. Indicates whether we can or cannot read from this MessagePacket. Notice that we cannot read from and write to a MessagePacket at the same time.
|
|
Tells if there are still some messages in the packet.
|
|
Sets the client index of the packet. Sets the client index of the packet, to facilitate its management in the server.
|
|
Returns the size in bytes of the message data.
|
|
Indicates if we can write to this MessagePacket. Indicates whether we can or cannot write to this MessagePacket. Notice that we cannot read from and write to a MessagePacket at the same time.
|