How to use the Remote Desktop Connection Broker client API

The Remote Desktop Connection Broker client API allows third party protocol vendors to leverage the Connection Broker to expedite the handling of connections that use their protocol to connect to virtual machines or Remote Desktop servers in a farm.


Step 1: Obtain the IConnectionBrokerClient interface

When your application or protocol provider is initialized, perform the following steps.

  1. Call the CBCreateClientInstance function to obtain the IConnectionBrokerClient interface.
  2. Keep the IConnectionBrokerClient interface as long as you need it.
  3. When the IConnectionBrokerClient interface is no longer needed, call the Release method.

Step 2: Request the target information

When your protocol provider receives an incoming connection request, perform the following steps to call the IConnectionBrokerClient::GetTargetInfo method. This method obtains, from the Connection Broker, the appropriate server to redirect the connection to.

  1. Create an event that can be signaled using the CreateEvent, or similar function, to use for the hStatusEvent parameter.
  2. Allocate memory for the pTargetInfo and pResult parameters. These memory blocks must remain in place until after this entire sequence is complete.
  3. Fill out a CB_CONNECTION_INFO structure that contains all of the information about the incoming connection.
  4. Call the GetTargetInfo method, passing all of the required parameters. This is an asynchronous method that will return an instance of the IConnectionBrokerRequest interface.
  5. Wait for the hStatusEvent event to become set.
  6. Whenever the hStatusEvent event is set, call the IConnectionBrokerRequest::CheckStatus method to determine the status of the request.
  7. When CheckStatus returns CB_STATUS_REQUEST_COMPLETED, the pTargetInfo and pResult parameters will contain their information. You can break out of the wait loop because the hStatusEvent parameter will no longer be used.
  8. Use the information in the CB_TARGET_INFO structure represented by the pTargetInfo parameter to determine where to redirect the incoming connection to.
  9. Release the IConnectionBrokerRequest interface.
  10. Close the hStatusEvent event handle, or you can reuse it for subsequent connection requests.