Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Message Class Reference

#include <message.h>

List of all members.

Public Methods

 Message (ost::TCPStream *stream)
 Construnct a message from the stream.

 Message (unsigned long int _organismId, bool _petition, MessageType _type, unsigned long int _size, const char *_msg)
 Construct a message with the specified parameters.

 ~Message ()
 Destroy a message. If the msg pointer is not null, it's deleted.

const void sendTo (ost::TCPStream *stream)
 Sends the message thought the stream.

string toString ()
 Converts the message to a string.


Public Attributes

unsigned long int organismId
bool petition
MessageType type
unsigned long int size
char * msg
 The message coded in a char *.

unsigned char * umsg
 The messahe coded in a unsigned char *.


Detailed Description

The message struct, all client messages are in this format. The sizes are specified, and even on machines with bigger word sizes, there is no problem just because I read the stream byte by byte and translate it. On these machines the only problem is that they waste memory.

Definition at line 52 of file message.h.


Constructor & Destructor Documentation

Message::Message ost::TCPStream *    stream
 

Construnct a message from the stream.

Create a message from a stream, the data is copied, and deleted when the message is deleted, so make your own copy!

Definition at line 52 of file message.cc.

References MessageType, msg, organismId, petition, size, and type.

Message::Message unsigned long int    _organismId,
bool    _petition,
MessageType    _type,
unsigned long int    _size,
const char *    _msg
 

Construct a message with the specified parameters.

Create a Message. Be carfull as the msg pointer is memcopied, it's slower but safer.

Definition at line 32 of file message.cc.

References MessageType, msg, organismId, petition, size, and type.

Message::~Message  
 

Destroy a message. If the msg pointer is not null, it's deleted.

Destroys the message. Just delete the msg pointer if it points to any data

Definition at line 92 of file message.cc.

References msg.


Member Function Documentation

const void Message::sendTo ost::TCPStream *    stream
 

Sends the message thought the stream.

Sends the message thought the stream

Definition at line 112 of file message.cc.

References msg, organismId, petition, size, and type.

Referenced by Client::clientLog(), Client::dropCylinder(), Client::endOfTurn(), Client::grow(), Client::move(), Client::newCylinder(), Client::sendEnergy(), and Client::sendMessage().

string Message::toString void   
 

Converts the message to a string.

Convert the message to a printable string

Definition at line 101 of file message.cc.

References organismId, petition, size, and type.


Member Data Documentation

char* Message::msg
 

The message coded in a char *.

Definition at line 65 of file message.h.

Referenced by Client::clientLog(), Client::dropCylinder(), Message(), Client::move(), Client::newCylinder(), Client::sendMessage(), sendTo(), and ~Message().

unsigned long int Message::organismId
 

The organism that send the message. 32 bits

Definition at line 55 of file message.h.

Referenced by Client::dropCylinder(), Client::grow(), Message(), Client::move(), Client::newCylinder(), Client::sendEnergy(), Client::sendMessage(), sendTo(), and toString().

bool Message::petition
 

If it's a petition or a response. 1 bit

Definition at line 57 of file message.h.

Referenced by Client::clientLog(), Client::dropCylinder(), Client::endOfTurn(), Client::grow(), Message(), Client::move(), Client::newCylinder(), Client::sendEnergy(), Client::sendMessage(), sendTo(), and toString().

unsigned long int Message::size
 

size of the message. 32 bits.

Definition at line 61 of file message.h.

Referenced by Client::clientLog(), Client::dropCylinder(), Client::grow(), Message(), Client::move(), Client::newCylinder(), Client::sendEnergy(), Client::sendMessage(), sendTo(), and toString().

MessageType Message::type
 

The message type. 15 bits

Definition at line 59 of file message.h.

Referenced by Message(), Client::Run(), sendTo(), and toString().

unsigned char* Message::umsg
 

The messahe coded in a unsigned char *.

Definition at line 67 of file message.h.

Referenced by Client::dropCylinder(), Client::grow(), Client::move(), Client::newCylinder(), Client::sendEnergy(), and Client::sendMessage().


The documentation for this class was generated from the following files:
Generated on Mon Jun 17 19:54:17 2002 for Svas Server by doxygen1.2.16