DirectPlay Tools and Samples

The following samples show how to use DirectPlay. These DirectPlay samples are included on the DirectX 6.0 CD-ROM. The Control Panel tool can be used to find out about DirectPlay applications. The DPSim tool can be used to test your DirectPlay applications.

DirectX Control Panel Tool

DPSim Simulation Service Provider Tool

DPSim provides a test and simulation environment for testing DirectPlay applications. It has two areas of functionality. It can simulate low bandwidth or high latency connections over a high-speed local area network and can generate random or programmed message transmission failures.

You can enter and edit the parameters that control DPSim, which are stored in the registry, by using the Configuration Manager, DPSimCfg.exe.

Using DPSim

DPSimCfg.exe is used to configure the registry parameters used by DPSim and to activate or deactivate it by adding or removing the Simulator Service Provider registry entry. When active, the Simulator Service Provider can be selected from the list of Service Providers. DPSim is implemented over the TCP/IP Service Provider.

There are four ways to drop message packets being sent to simulate communication failures.

  1. A certain percentage of the packets can be randomly dropped.
  2. Every Nth packet can be dropped.
  3. You can use a defined pattern, for example, number packets passed, number packets dropped, number passed, number dropped, and so on. The pattern is series of numeric values separated by a comma or a space. The pattern will repeat itself when the end of the sequence is reached.
  4. No packets are dropped.

Packet dropping can be specified not to occur until a certain period (in milliseconds) after communication starts, and it can be specified to last for a certain period ( in milliseconds). These periods are defined with the Start After and Stop After parameters. If Stop After is zero, packet dropping will continue indefinitely.

A check box exists for dropping guaranteed messages.

A latency (in milliseconds) can be added to both sent messages and received messages. Each latency can also have a +/- variance range, evenly distributed.

Instead of a latency, a simulated bandwidth can also be specified for both sending and receiving.

Note that for fine adjustment of the slider controls, you can click on the slider controls and use the arrow keys to increase or decrease the value.

Lobby Server Application

Using the Lobby Server Application

To initialize the lobby server in its default mode, select the Server menu, and choose Start. The lobby server will create several default top-level groups. Users will only be allowed to create sub-groups within the top-level groups, staging areas, or shortcuts to staging areas.

For your convenience, the lobby server application also provides a test mode in which no top level groups are automatically created. Users are free to create any group hierarchy they want, to any depth. If you want to set the lobby server into test mode, you must do so before you select Start from the Server menu. To set the lobby server into test mode, select Server from the lobby application's main menu. Choose Test Mode from the Server menu. You can now start the lobby server in test mode by choosing Start from the Server menu.

If you choose Secure Mode in the Server menu before selecting Start and the lobby server running on Windows NT 4.0 or later, the lobby server will require clients to login.

The lobby server will ask which service provider to use. All clients connecting to the server will need to select this same service provider. You will then be asked to provide a name for the lobby server session.

Bellhop Sample

Using Bellhop

After launching bellhop, you will be asked to select a lobby provider. This is the lobby server application installed as part of the SDK. It must be running before Bellhop is started. If the lobby provider is running, choose Lobby Connection for DirectPlay.

You will then be presented with a dialog asking you to select a service provider. The sample lobby server and lobby provider are capable of operating over any network supported by DirectPlay. Select an appropriate service provider (such as TCP/IP), and choose OK.

With a TCP/IP connection, you will be prompted for the address of the lobby server. You can leave this blank to try to find the address on your local network. Alternatively, you can enter the computer name or IP address. When the lobby server name is displayed, join it.

You will be presented with a player character that represents you in the virtual gaming environment. To move your player from doorway to doorway, double-click the doorway you wish to enter. You can also drag and drop the icon representing your player to the doorway.

You will only see the contents of rooms that you have joined. Once you leave a room, all the doorways and players in that room will disappear.

Bellhop provides context-sensitive menus. If you right click on a player or group, the Bellhop program will display the options available for that specific item. If you right click on the background, you can choose to refresh its display. Bellhop will re-enumerate all the groups and players that are available to you.

When you want to create a sub-folder or staging area in an existing folder, right-click the folder. In the menu that appears, select Create Group In Group. If you choose to create a staging area, you will need to select which game to play from the listbox. Bellhop will only list applications that are registered with DirectPlay. Any other applications that may be running on the network are ignored. In addition to selecting a game, you must choose which connection will be used to launch the game. You can optionally specify a password for the session and the maximum number of players.

If you want to join a staging area, you can right click on its icon and select Get Group Connection Settings in the menu that appears. Bellhop will show you properties of the staging area. You can modify these settings using Set Group Connection Settings.

To start a game from a staging area, right click on the staging area icon and select Start Session. This will launch the application on the machines of all the people in the staging area and connect them together in a session. If you move into the staging area after the session has started, select Start Session to join the session in progress. If the session is in progress, the icon will change from a green triangle to a red and black triangle.

You can create a shortcut to a room by dragging and dropping one doorway on top of another. The icon will appear as a doorway surrounded by a magic portal.

To change the name of local groups or players, right-click the group or player and select Set Group Name in the menu that is displayed. When you do, another menu appears. Choose Set Player Name. Alternately you can single click on the text of the group or player name.

Spectators within the lobby are treated the same as players.

There is optional support for allowing players in multiple rooms simultaneously. To enable it, uncomment the code in the CreatePlayer section of CGroupTree and rebuild. For every player created, a player is added to the root of the tree control. You can enter simultaneous rooms by dragging the player icon from the top level onto a doorway.

DPChat Sample

Using DPChat

Use either the DPLaunch or Bellhop application to run DPChat. You can start a new chat session or connect to one already in progress.

DPLaunch Sample

Using DPLaunch

When you run it, DPLaunch presents you with a pull-down list of all registered DirectPlay applications on your computer. Once you choose which application to start, you must also select the connection method, and specify your player name. In addition, you need to pick a session name, and specify whether you are joining an existing session or creating a new one. If you know the IP address of a computer hosing a DirectPlay session, you can specify that as well.

DPSlots Sample

Using DPSlots

DPSlots is really two applications in one. When you host a session, it acts as a server. When you join a session, it acts as a client.

The server maintains a simple database of account balances for every user that is allowed to log in. Clients can request their current balance from the server. They can also request that the server spin the wheels and calculate the amount won or lost. The server maintains a simple text file "database" called Slotsdb.txt. The DPSlots program uses this file to record the balance for each user. Each line of the text file contains the user account ID and a 8-character balance figure separated by a comma, as shown in the following example.

Account1,    1000
Account2,     500

You need to add lines manually to this file for each user.

When you join a session, DPSlots acts as a client and sends messages to the server for all operations. After requesting a spin from the server, it animates the tumblers and displays the results. The client can be required to log the user into the server using a name and password.

DPSlots can be hosted using security by clicking the Require Secure Login checkbox after choosing to host. By leaving the Security Provider editbox blank the default NTLM security package will be used. If you have an alternate SSPI security package installed, it can be specified here.

Once you have a security provider, the server will host a secure session. Clients will have to securely log in with a user name and a password before being allowed access the session on the server. All messages between the client and server will be digitally signed and encrypted.

When hosting a secure server, the account ID for each user will be defined by the security package being used. This account ID must be stored in the database file along with the appropriate balance. The default security package is NTLM, which uses a domain and a user name for the account ID. If, for example, you use NTLM, your domain is "GAMES", and you have two users "Bob" and "Jane", your database file would be as shown in the following example.

GAMES/Bob,    1000
GAMES/Jane,     500

Currently you can only host a secure session using NTLM on a Windows NT workstation or server. However, you can log into the server from Windows 95 or Windows NT.

Duel Sample

Using Duel

Your computer must be connected to the network for Duel to work. When you launch the application, you can chose to host a new game or join an existing game. When the program displays its splash screen, press the Enter key to begin playing.

All players in the game are represented by a small space ship in an asteroid field. Use the left and right arrows to turn the ship left and right. The up arrow accelerates your ship forward. The down arrow accelerates it backward. Press the space bar to fire. To exit the game, press Esc or F12.

To play using TCP/IP over the Internet, the people who are joining the game must enter the IP address of the machine that hosted the game. You can find out the IP address of your machine by running the Winipcfg utility that comes with Windows 9x and Windows NT. If you have a network card and a modem installed, you will need to make sure you read the IP address of the modem connection to the Internet. The modem will show up as a PPP Adapter. This game will not work through proxies or firewalls.

Override Sample

Using Override

When the program begins, select a service provider. Once you make your selection, the application displays a custom dialog box that it creates to collect the information needed for that service provider. If you select an unknown service provider, then the service provider's dialog cannot be overridden and the Override application simply displays the default dialog box.

Once the service provider information has been collected from the user, it must be formatted into a DirectPlay Address. This can be used to initialize the service provider.

The IDirectPlay4::EnumSessions and IDirectPlay4::Open methods must be called with the dwFlags parameter set to the value DPENUMSESSIONS_RETURNSTATUS. This will suppress any status dialogs that may pop up to show to progress of the connection.


Top of Page Top of Page
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.