Microsoft DirectX 8.0 (Visual Basic)

Communicating with a Lobbyable Game

Communication between a lobby client and its associated lobby server can be handled in any way that is convenient. Microsoft® DirectPlay® specifies only how the lobby client must communicate with a lobbyable game application.

Lobby clients do not communicate directly with game applications. Instead, they communicate with the DirectPlay8LobbyClient object. If the game application is lobbyable, the lobbied application object then passes messages to the game. The DirectPlay8LobbyClient object enables the lobby client to do the following.

Note  A DirectPlay lobby client can launch any application, whether or not it is lobbyable. However, only lobbyable applications can use DirectPlay to communicate back to the lobby client during the course of the game.

The lobby client object communicates with the lobby client through a DirectPlay8LobbyEvent message handler object. The DirectPlay8LobbyEvent object is essentially an event handler that receives notifications directly from the lobby client object, and indirectly from the application. It is not provided by DirectPlay and must be implemented by your application. See the reference documentation for details. You must register this object with DirectPlay by calling DirectPlay8LobbyClient.RegisterMessageHandler.

The DirectPlay8LobbyEvent object enables the lobby client object to send the lobby client information such as:

Launching an Application

When you launch an application, you can attempt to pass a block of game-specific information to the application. When a lobbyable application is launched by a lobby client, the application creates and initializes a lobbied application object. The information is passed to the game through the initialization method.

When the lobbied application object is initialized, the lobby client receives a message indicating that the user has been connected. One primary purpose of this message is to notify the lobby client that the application is lobbyable. If the lobby client has not received a connect message after a reasonable period of time following the launch, the game is not lobbyable and you can stop attempting to make this connection.

After Launching an Application

The lobby client has relatively little to do once a lobbyable game is in progress. Depending on the game topology, most of the user's messages are sent directly to the other players or to the game server,. However, DirectPlay sends the lobby client messages in response to events such as disconnection and host migration. These messages enable the lobby client to pass such status changes to the lobby server. For instance, if the host migrates, the lobby server can update its UI to indicate the new host.

The application can also pass messages to the lobby client. This message can contain virtually anything, and it can be used for any purpose. The lobby client typically passes the data to the lobby server for processing. For example, at the end of the game, the application might send a message that enables the lobby server to update its high-score list.