?/TD>
Microsoft DirectX 9.0

Initiating a Client/Server Session


A client/server game can be launched through a lobby, or directly by the server application.

The Server Application

Client/server games are often arranged through lobbies. The most straightforward way to launch the server is to implement it as a lobbyable application. This approach provides a way to launch the server, and supports communication between server and lobby during the course of the session. See DirectPlay Lobby for further discussion.

A server can also be directly launched, and then advertise itself as available and wait for clients to connect. See Selecting a Client/Server Host for details.

Once the server application has been launched, it should initialize itself by calling IDirectPlay8Server::Initialize. As with other similar Microsoft?DirectPlay?methods, the primary purpose of initialization is to provide DirectPlay with a pointer to your callback message handler. You should also call IDirectPlay8Server::SetServerInfo to describe the current game. Clients cannot connect to a server until this method has been called.

The Client Application

One of the first steps you should take is to determine whether your game was lobby-launched. To do so, create and initialize a lobbied application object (CLSID_DirectPlay8LobbiedApplication ). When you do so, you pass the object a pointer to your lobbied application message handler. This message handler receives messages directly from the lobbied application object, and indirectly from the lobby client and the lobby.

You should also create and initialize a client object (CLSID_DirectPlay8Client ). This object will be your primary means of communicating with DirectPlay and the server. If you want to have multiple players in the session, you must create a separate instance of this object for each player.



© 2002 Microsoft Corporation. All rights reserved.