|
Message Manager
C4Messages.h
class Message
Base class for all message types.
Definition
class Message : public ListElement<Message>, public Memory<MessageMgr>
Member Functions
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. - 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. - 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. - 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
See Also
MessageMgr
|