Message Manager
C4Messages.h

class Message

Base class for all message types.
Definition

class Message : public ListElement<Message>, public Memory<MessageMgr>

Member Functions
Message::GetMessageType Returns the dynamic type identifier of a message.
Message::GetMessageFlags Returns flags which indicate whether a message requires special handling.
Message::SetMessageFlags Sets flags which indicate whether a message requires special handling.
Message::Compress Called by the Message Manager to compress and serialize message data into a memory buffer.
Message::Decompress Called by the Message Manager to decompress and validate message data stored in a memory buffer.
Constructor

Message(MessageType type, unsigned long flags = 0);

Parameters
type The type of message.
flags The message flags.
Description
Every type of message is encapsulated by a subclass of the Message class. The type parameter passed to the Message constructor identifies the type of message being constructed and should be passed in from the constructor of a subclass.

Each subclass of the Message class must implement the following three functions.
  1. A default constructor which takes no parameters. When the Message Manager receives a message having an application-defined type, it calls the Application::ConstructMessage function with the message type, and this function should return a newly constructed Message subclass corresponding to that type. The default constructor should not initialize any data fields because the Message Manager subsequently calls the object's Decompress function to initialize the object using data from the received network packet.
  2. A Compress function. The Message Manager calls this function to compress and serialize the message into a buffer which will be sent as a data packet.
  3. A Decompress function. The Message Manager calls this function to decompress a data packet into the message object and validate its contents.
Subclasses of the Message class may have, in addition to the default constructor, constructors which take initializers. Such a constructor would be useful for creating a new message which is to be sent to another machine.
Base Classes
ListElement<Message> Used internally by the Message Manager.
Memory<MessageMgr> Memory for Message objects is allocated in the Message Manager's heap.
See Also
MessageMgr