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
- Lobby Server Application
- Bellhop Sample
- DPChat Sample
- DPLaunch Sample
- DPSlots Sample
- Duel Sample
- Override Sample
DirectX Control Panel Tool
- Found in Control Panel. Double-click to open the DirectX Properties dialog box.
- The DirectPlay tab displays all the registered DirectPlay service providers and applications.
- Open the DirectX Properties dialog box before starting a DirectPlay application to see on-the-fly statistics about DirectPlay communications such as bytes per second and messages per second.
DPSim Simulation Service Provider Tool
- Found in Mssdk\Samples\Multimedia\DPlay\bin\DPSim.dll. The tool to configure DPSim is found in Mssdk\Samples\Multimedia\DPlay\bin\DPSimCfg.exe. The DPSim.dll needs to be copied to Windows' system directory (system32 on Windows NT).
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.
- A certain percentage of the packets can be randomly dropped.
- Every Nth packet can be dropped.
- 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.
- 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
- Found in Mssdk\Samples\Multimedia\DPlay\bin\LServer.exe.
- Provides the functionality to establish a multiplayer DirectPlay session.
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
- Sources found in Mssdk\Samples\Multimedia\DPlay\Bellhop. Executable found in Mssdk\Samples\Multimedia\DPlay\bin\Bellhop.exe.
- A lobby client program that uses the IDirectPlay4 interface to communicate with a lobby server.
- Uses the LServer test lobby server so that a real lobby client/server environment can be set up. The lobby server application must be running for Bellhop to work. When users run Bellhop, you are presented with virtual environment in which you can meet others, begin games with them, and join in games that are already running.
- Bellhop can be used to test external lobby support in your application.
- LServer can be used as a test server to write your own lobby client or integrate a lobby client into your application.
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
- Sources found in Mssdk\Samples\Multimedia\DPlay\DPChat. Executable found in Mssdk\Samples\Multimedia\DPlay\bin\DPChat.exe.
- A simple Windows-based chat program that uses IDirectPlay4 to establish a chat session over the network.
- Uses IDirectPlayLobby3 to make it lobby-able.
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
- Sources found in Mssdk\Samples\Multimedia\DPlay\DPLaunch. Executable found in Mssdk\Samples\Multimedia\DPlay\bin\DPLaunch.exe.
- A stand-alone application that demonstrates how a DirectPlay 6.0 application can be launched from an external source using the IDirectPlayLobby3 interface.
- Can also be used to test the lobby support in your application.
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
- Sources found in Mssdk\Samples\Multimedia\DPlay\DPSlots. Executable found in Mssdk\Samples\Multimedia\DPlay\bin\DPSlots.exe.
- A DirectPlay client/server application that simulates a slot machine and uses security.
- The server controls all the slot machines and tracks how much money each player has.
- The client securely logs in to the server.
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, 500You 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, 500Currently 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
- Sources found in Mssdk\Samples\Multimedia\DPlay\Duel. Executable found in Mssdk\Samples\Multimedia\DPlay\bin\Duel.exe.
- A multiplayer game that uses the IDirectPlay interface.
- Uses IDirectPlayLobby to make it lobby-able.
- Demonstrates the use of DirectDraw for animation, the use of DirectInput for obtaining keyboard input, and the use of DirectSound for generating sound effects in games.
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
- Sources found in Mssdk\Samples\Multimedia\DPlay\Override. Executable found in Mssdk\Samples\Multimedia\DPlay\bin\Override.exe.
- A simple demonstration of how to override the DirectPlay service provider dialogs.
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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.