Platform SDK: DirectX

Staying in Touch with the Lobby

After being launched by a lobby, or after connecting dynamically, your application might want to continue exchanging information with the lobby. For example, the lobby server might want to keep track of how many players are currently in the game, or their scores, in order to display this information to other users in the lobby. Similarly, the application might want to receive data such as player or game configurations where these were set in the lobby rather than in the application itself.

[C++]

You can exchange messages with the lobby by using the IDirectPlayLobby3::SendLobbyMessage and IDirectPlayLobby3::ReceiveLobbyMessage methods.

Information is sent to the lobby by setting properties. The application must create and fill in a DPLMSG_SETPROPERTY message structure and send it to the lobby by using the SendLobbyMessage method. Each property identifies a distinct type of data. At design time, the application developer assigns GUIDs to each property that can be set. The lobby operator needs to obtain this list of GUIDs from the application developer along with the description and data structure of each property.

An application can request confirmation that the property was set correctly by supplying a nonzero value in DPLMSG_SETPROPERTY.dwRequestID. The lobby then replies by sending a DPLMSG_SETPROPERTYRESPONSE message.

Information is obtained from the lobby in a similar fashion, by requesting properties. The application fills in a DPLMSG_GETPROPERTY structure and sends it to the lobby by using the SendLobbyMessage method. The lobby sends back a DPLMSG_GETPROPERTYRESPONSE structure containing the property data that was requested. As before, the application developer generates the GUIDs for each property and shares these with the lobby developer.

Not all lobbies will be able to support these standard lobby messages. The application can determine whether the lobby that it was launched from supports standard lobby messages by sending a DPLMSG_GETPROPERTY message requesting the DPLPROPERTY_MessagesSupported property.

For more information, see DirectPlay Defined Properties.

[Visual Basic]

You can exchange messages with the lobby by using the DirectPlayLobby3.SendLobbyMessage and DirectPlayLobby3.ReceiveLobbyMessage methods.

Information is sent to the lobby by setting properties. The application must create a DirectPlayMessage object containing data in the same order as in the DPLMSG_SETPROPERTY C structure, using the DirectPlayMessage.WriteLong and DirectPlayMessage.WriteGuid methods.

Information is obtained from the lobby in a similar fashion, by requesting properties. The application creates a message containing data equivalent to that in the DPLMSG_GETPROPERTY C structure and sends it to the lobby. The lobby sends back a DPLMSG_GETPROPERTYRESPONSE message containing the property data that was requested. Data can be extracted by using the DirectPlayMessage.ReadLong and DirectPlayMessage.ReadGuid methods.

For more information, see the C++ text for this topic.