?/TD>
Microsoft DirectX 9.0

ChatPeer


The ChatPeer sample is similar in form to SimplePeer. When a player hosts or connects to a session, the players can chat with each other by passing text strings.

Path

Source: (SDK root)\Samples\C++\DirectPlay\ChatPeer

Executable: (SDK root)\Samples\C++\DirectPlay\Bin

User's Guide

Enter the player's name and choose a connection type. You can choose "Wait for Lobby Connection" or choose a service provider. Use the Multiplayer Games dialog box to either search for an active game to join or to start a new game. When you join or start a game, you can begin immediately. Other players can join the game at any time. If host migration is on, the host player can also leave at any time, because Microsoft?DirectPlay?will automatically migrate the host session to another player.

Note  If you choose the Internetwork Packet Exchange (IPX) service provider and want to have DirectPlay perform a search for the address, select the use DPNSVR check box.

Programming Notes

The ChatPeer sample is very similar in form to the SimplePeer sample. The ChatPeer differs by letting clients send text string to all players connected to the session. For detailed programming notes, see the Programming Notes section of the SimplePeer sample.

When Send is pressed, the SendChatMessage function does the following:

  1. Retrieves the text string from the dialog box.
  2. Fills an application-defined structure, GAMEMSG_CHAT. This structure has a message type identifier (ID) as the first BYTE. This lets the application figure out what type of application message was received. However, ChatPeer uses only one application-defined message. See StagedPeer for a more complex example of this process.
  3. Fills out a DPN_BUFFER_DESC structure using the GAMEMSG_CHAT buffer.
  4. Calls IDirectPlay8Peer::SendTo with the DPN_BUFFER_DESC. It passes the DPNID_ALL_PLAYERS_GROUP flag, so this message goes to everyone.


© 2002 Microsoft Corporation. All rights reserved.