C4 Engine
C4 Engine API Documentation

MessageMgr::SendMessage

Defined in:  C4Messages.h
Sends a message to a player in a multiplayer game.
Prototype

void SendMessage(PlayerKey key, const Message& message);

Parameters
key The key of the player that the message will be sent to.
message The message to be sent.
Description
The SendMessage function locates the player whose key matches the key parameter and sends the message given by the message parameter to that player. If no player with the specified key exists, then SendMessage returns without sending the message.

The key parameter may be the actual key of a player, or it may be one of the following special constants.
kPlayerServer The message is sent to the server. If the local machine is the server, then the message is received immediately and is processed before SendMessage returns.
kPlayerSelf The message is sent to the local machine. The message is received immediately and is processed before SendMessage returns.
kPlayerAll The message is sent to all players and to the local machine. Specifying this key is equivalent to calling the MessageMgr::SendMessageAll function.
kPlayerClients The message is sent to all client machines. This may only be specified if the sending machine is the server, and it is equivalent to calling the MessageMgr::SendMessageClients function.
Messages may be sent only to remote machines for which an actual connection with the local machine exists. Since client machines are normally connected only to the server, messages may not be sent directly from client to client. A call to the SendMessage function has no effect if there is no connection corresponding to the recipient.
Special Considerations
If a pointer to a Player object is available, it is generally better to call Player::SendMessage to send a message to that player instead of calling MessageMgr::SendMessage with the player's key.
See Also

MessageMgr::SendMessageAll

MessageMgr::SendMessageClients

MessageMgr::SendConnectionlessMessage

Player::SendMessage