Microsoft DirectX 9.0


The VoiceConnect sample shows how to network with other players to start a Microsoft?DirectPlay?Voice chat session. After joining or creating a session, the players can use a microphone to talk to one other. Other players can join the session at any time.


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

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

User's Guide

For information about how to connect, refer to the User's Guide section of the SimplePeer sample. After connecting, the host is presented with a dialog box asking which voice codec to use. Typical voice applications automatically select a voice codec, or present this to the user in some other fashion. Once the chat session begins, any client can alter the playback or capture settings by clicking Setup.

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 VoiceConnect sample is very similar in form to the SimplePeer sample. The VoiceConnect differs by letting clients use DirectPlay Voice to talk to each other using a computer microphone. For detailed programming notes, see the Programming Notes section of the SimplePeer sample.

To create the voice functionality, the application must first initialize DirectPlay voice. This sample does this by calling CNetVoice::Init when the main dialog is initialized. CNetVoice::Init performs the following tasks.

DirectPlayVoiceClientMessageHandler handles different DirectPlay messages such as:

When Exit is clicked, the application needs to clean up DirectPlay Voice by calling CNetVoice::Free, which does the following:

  1. Disconnects the player from the voice session. The VoiceSessionDisconnect function calls IDirectPlayVoiceClient::Disconnect and releases the IDirectPlayVoiceClient object.
  2. Destroys the voice session if this player is the host. The VoiceSessionDestroy function calls IDirectPlayVoiceServer::StopSession and releases the IDirectPlayVoiceServer object

© 2002 Microsoft Corporation. All rights reserved.