Application::ReceiveMessage
Defined in:
Called when an application-defined message is received.
C4Application.h
Prototype
virtual void ReceiveMessage(Player *sender, const NetworkAddress& address, const Message *message);
Parameters
sender |
The player from whom the message originated. |
address |
The address of the machine from which the message originated. This is only valid for connectionless messages. |
message |
The message being received. |
Description
When the Message Manager receives a message with an application-defined type, it calls ReceiveMessage
so that the application module may handle the message in whatever way it needs to. The implementation of the ReceiveMessage
function should determine the type of the message object pointed to by the message
parameter by calling Message::GetMessageType
and then handle the message appropriately.If a connection exists with the sending machine, the
sender
parameter contains a pointer to the sending player. (On client machines, this player will always represent the server.) If the received message was sent without a connection, then the sender
parameter is nullptr
, and the network address of the sending machine is given by the address
parameter.
See Also