Microsoft DirectX 8.1 (C++)

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\Multimedia\DirectPlay\LobbyClient

Executable: (SDK root)\Samples\Multimedia\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 done mainly for demonstration purposes. A more complex lobby client might want to use this functionality in a more meaningful way by passing a message to which the lobbied application responds.

Programming Notes

The InitDirectPlay() function does the following:

  1. Initialize COM with CoInitialize().
  2. Create an IDirectPlay8Peer object with CoCreateInstance().
  3. Call IDirectPlay8Peer::Initialize to tell the interface about our message handler.
  4. Create an IDirectPlay8LobbyClient object with CoCreateInstance().
  5. Call IDirectPlay8LobbyClient::Initialize to tell the interface about our lobby message handler.

The OnInitDialog() function does the following:

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

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

  1. Fill 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. Call IDirectPlay8LobbyClient::ConnectApplication() passing in the DPL_CONNECT_INFO structure.
  3. Free 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_DISCONNECT The lobbied application was disconnected. The pDisconnectMsg–>hDisconnectId parameter will contain the handle of the lobbied application that was disconnected and the pDisconnectMsg–>hrReason parameter will contain the reason. This sample pops up a message box.
DPL_MSGID_RECEIVE The lobbied application sent the client data. This sample does not respond to any message.
DPL_MSGID_SESSION_STATUS A lobbied application has changed its status. The pStatusMsg–>hSender parameter will be one of several predefined status codes. This sample updates the UI, showing that the lobby status has been updated. However, more complex lobby clients many want to take action.
DPL_MSGID_CONNECTION_SETTINGS A lobbied application has changed its connection settings. This lobby client takes no action. However, more complex clients might want to 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.