Microsoft DirectX 8.1 (C++)

AddressOverride

AddressOverride demonstrates how to programmatically provide an address to Microsoft® DirectPlay® in order to host or connect to another session on the network. The alternative is to have DirectPlay display a standard dialog box to ask the user the connection settings. Most games will typically set addresses directly, so that they can provide their own user interface.

Path

Source: (SDK root)\Samples\Multimedia\DirectPlay\AddressOverride

Executable: (SDK root)\Samples\Multimedia\DirectPlay\Bin

User's Guide

The AddressOverride sample displays a dialog box that allows you to select address parameters. To use the dialog box:

  1. Enter the player's name and session.
  2. If you want to be a session host, select the Host Session check box.
  3. Choose a service provider from the Service Provider list.
  4. Choose an adapter from the Adapter list.
The remaining steps depend on which service provider you choose.

Once you have finished filling in the Address Override dialog box, click OK to start or join a game. This game is similar to SimplePeer. See the SimplePeer user's guide for more details.

Programming Notes

The AddressOverride sample is very similar to the SimplePeer sample. See the Programming Notes section of the SimplePeer sample for details. AddressOverride differs by programmatically specifying an address, rather than having DirectPlay display the default address selection dialog box.

The following list outlines how the AddressOverride sample works. Once the OK button is pressed, the sample:

  1. Determines whether the user wants to host or join a session from the Host Session check box.
  2. Determines the service provider from the Service Provider list, and selects the appropriate globally unique identifier (GUID).
  3. Creates an IDirectPlay8Address object called pDeviceAddress.
  4. Calls that object's IDirectPlay8Address::SetSP method to specify the service provider.
  5. If the user is hosting a session, creates an IDirectPlay8Address object called pHostAddress. It then calls that object's IDirectPlay8Address::SetSP method to specify the service provider.
  6. If an adapter was specified, the sample calls the pDeviceAddress object's IDirectPlay8Address::SetDevice() to specify the adapter.

The sample then calls IDirectPlay8Address::AddComponent to complete the initialization of the address objects. The details depend on which service provider was selected, and whether the user is joining or hosting a session.

Use the device and host address objects to connect to the session, much like the SimplePeer sample.