Microsoft DirectX 8.1 (Visual Basic)

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 Lobbies 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 register it's DirectPlay8Event notification handler object. The DirectPlay8Event object is essentially an event handler that receives notifications from Microsoft® DirectPlay® . It is not provided by DirectPlay and must be implemented by your application. See the reference documentation for details. You should also call DirectPlay8Server.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 a DirectPlay8LobbiedApplication object and a DirectPlay8LobbyEvent object. Register the DirectPlay8LobbyEvent object with Microsoft® DirectPlay® by calling DirectPlay8LobbiedApplication.RegisterMessageHandler. The DirectPlay8LobbyEvent object is essentially an event handler that receives notifications directly from the lobbied application object, and indirectly from the lobby client and the lobby. It is not provided by DirectPlay and must be implemented by your application. See the reference documentation for details.

If the application was lobby-launched, DirectPlay will call your DirectPlay8LobbyEvent.Connect method. The dlNotify parameter will contain a DPL_MESSAGE_CONNECT type with connection information. such as address objects for the members of the session.

You should also create a DirectPlay8Client object and register a DirectPlay8Event notification handler object by calling DirectPlay8Client.RegisterMessageHandler. These objects will be your primary means of communicating with the server.