Once an application has created a player within a session, it can start exchanging messages with other players in the session. DirectPlay imposes no message format or extra bytes on the message. A message can be sent to an individual player, to all the players in the sessions, or to a subset of players that have been defined as a group (see Group Management). When sending a message it must also be marked as being from a specific local player.
All the messages received by an application are put into a receive queue. The application must retrieve individual messages from the queue and act on them as appropriate. The application can either poll the receive queue for messages or use a separate thread that waits on a synchronization event for notification that a new message has arrived.
There are two types of messages. Player messages are messages that another player in the session sent. This type of message is directed to a specific player and is marked as being from the sending player. System messages are sent to all the players in a session and are all marked as being from the system (DPID_SYSMSG). DirectPlay generates system messages to notify the application of some change in state of the session; for example, when a new player has been created. See Using System Messages for more information.
Basic Message Management Methods
DirectPlay provides several message management methods:
·IDirectPlay3::Send sends a message from a local player to another player in the session.
·IDirectPlay3::SendChatMessage enables players to chat with other players using standardized messages.
·IDirectPlay3::Receive retrieves a message from the incoming message queue.
·IDirectPlay3::GetMessageCount gets the number of messages currently in the incoming message queue.