Platform SDK: DirectX |
This topic pertains only to application development in C++. See DirectPlay Visual Basic Samples.
The DPSlots sample is a client/server slot machine simulator that uses security features of DirectPlay.
The server controls all the slot machines and tracks how much money each player has. The client securely logs on to the server.
Source: (SDK root)\Samples\Multimedia\DPlay\Src\DPSlots
Executable: (SDK root)\Samples\Multimedia\DPlay\Bin\DPSlots.exe
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 allowed to log on. 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 database called Slotsdb.txt that records 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, entering the network user names in place of "Account1" and so on.
When you join a session, DPSlots acts as a client and sends messages to the server for all operations. The client can be required to log the user onto the server using a name and password.
DPSlots can be hosted using security by clicking the Require Secure Login checkbox after choosing to host. If you leave the Security Provider text box blank, the default NTLM security package is 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 have to securely log on with a user name and a password before being allowed to join the session. All messages between the client and server are digitally signed and encrypted.
When hosting a secure server, the account ID for each user is 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 or Windows 2000 workstation or server.