?/TD>
Microsoft DirectX 9.0

LobbyClient


LobbyClient is a simple lobby client application. It displays all registered Microsoft?DirectPlay?applications on the local system. It enables the user to launch one or more of these applications using a chosen service provider. A launched lobbied application can be told to either join or host a game.

Path

Source: (SDK root)\Samples\C++\DirectPlay\LobbyClient

Executable: (SDK root)\Samples\C++\DirectPlay\Bin

User's Guide

The LobbyClient sample displays a dialog box that allows you to choose launch parameters before starting the application by clicking Launch App. The Active Connections list will display the handle to all current lobbied applications. Clicking Send Message will send a lobby message to the lobbied application. This is done mainly for demonstration purposes. In a more complex lobby client, you might want to use this functionality in a more meaningful way by passing a message to which the lobbied application responds.

Note  If you choose the Internetwork Packet Exchange (IPX) service provider and want to have DirectPlay perform a search for the address, select the use DPNSVR check box.

Programming Notes

The InitDirectPlay function does the following:

  1. Initializes Component Object Model (COM) with CoInitialize.
  2. Creates an IDirectPlay8Peer object with CoCreateInstance.
  3. Calls IDirectPlay8Peer::Initialize to tell the interface about our message handler.
  4. Creates an IDirectPlay8LobbyClient object with CoCreateInstance.
  5. Calls IDirectPlay8LobbyClient::Initialize to tell the interface about our lobby message handler.

The OnInitDialog function does the following:

  1. Enumerates the registered lobbied applications and display them in the list box. See EnumRegisteredApplications.
  2. Enumerates the DirectPlay service providers and display them in the list box. See EnumServiceProviders.
  3. Whenever a new service provider is selected (and upon initialization), enumerates the service provider's adapters. See EnumAdapters.

When Launch App is clicked, the LaunchApp function does the following:

  1. Fills out a DPL_CONNECT_INFO structure. This is complex because it contains the host and device addresses as well as the DPN_APPLICATION_DESC. See LaunchApp and AllocAndInitConnectSettings.
  2. Calls IDirectPlay8LobbyClient::ConnectApplication passing in the DPL_CONNECT_INFO structure.
  3. Frees the DPL_CONNECT_INFO structure. This is complex because this structure has a number of DirectPlay addresses. See FreeConnectSettings.

The DirectPlayLobbyMessageHandler function can handle the following messages.

DPL_MSGID_DISCONNECTThe lobbied application was disconnected. The pDisconnectMsg?gt;hDisconnectId parameter will contain the handle of the lobbied application that was disconnected and the pDisconnectMsg?gt;hrReason parameter will contain the reason. This sample pops up a message box.
DPL_MSGID_RECEIVEThe lobbied application sent the client data. This sample does not respond to any message.
DPL_MSGID_SESSION_STATUSA lobbied application has changed its status. The pStatusMsg?gt;hSender parameter will be one of several predefined status codes. This sample updates the user interface (UI), showing that the lobby status has been updated. However, more complex lobby clients might take action.
DPL_MSGID_CONNECTION_SETTINGSA lobbied application has changed its connection settings. This lobby client takes no action. However, more complex clients might take action.

When Send Message is clicked, the SendMsgToApp function calls IDirectPlay8LobbyClient::Send. The hConnection parameter is set to the handle of the receiving lobbied application and the pBuffer parameter is set to the message buffer.

When Disconnect is clicked, the DisconnectFromApp function calls IDirectPlay8LobbyClient::ReleaseApplication. The hApplication parameter is set to the handle of the lobbied application from which to disconnect.



© 2002 Microsoft Corporation. All rights reserved.