Platform SDK: DirectX

Step 2: Retrieve the Connection Settings

[Visual Basic]

This tutorial pertains only to applications written in C++. See DirectPlay Visual Basic Tutorials.

[C++]

After the DirectPlayLobby object has been created, use the IDirectPlayLobby3::GetConnectionSettings method to retrieve the connection settings returned from the lobby. If this method returns DPERR_NOTLOBBIED, the lobby did not start this application, and the user will have to configure the connection manually. If any other error occurs, your application should report an error that indicates that lobbying the application failed.

The following example shows how to retrieve the connection settings:

// Get connection settings from the lobby (into g_pdplConnection).
hr = g_pDPLobby->GetConnectionSettings( 0, NULL, &dwSize );
if ( FAILED(hr) && (DPERR_BUFFERTOOSMALL != hr) )
{
    if( DPERR_NOTLOBBIED == hr )
    {
        *pbLaunchedByLobby = FALSE;
 
        // Clean up since we were not launched from the lobby.
        SAFE_DELETE_ARRAY( g_pDPLConnection );
        SAFE_RELEASE( g_pDPLobby );
 
        return S_OK;
    }
 
    return hr; 
}
 
// Allocate memory for the connection.
SAFE_DELETE_ARRAY( g_pDPLConnection );
g_pDPLConnection = (DPLCONNECTION*)new BYTE[ dwSize ];
 
// Get the connection settings.
if ( FAILED( hr = g_pDPLobby->GetConnectionSettings( 
         0, g_pDPLConnection, &dwSize ) ) )
    return hr;

Next: Step 3: Configure the Session Description