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.
When your application or protocol provider is initialized, perform the following steps.
- Call the CBCreateClientInstance function to obtain the IConnectionBrokerClient interface.
- Keep the IConnectionBrokerClient interface as long as you need it.
- When the IConnectionBrokerClient interface is no longer needed, call the Release method.
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.
- Create an event that can be signaled using the CreateEvent, or similar function, to use for the hStatusEvent parameter.
- Allocate memory for the pTargetInfo and pResult parameters. These memory blocks must remain in place until after this entire sequence is complete.
- Fill out a CB_CONNECTION_INFO structure that contains all of the information about the incoming connection.
- Call the GetTargetInfo method, passing all of the required parameters. This is an asynchronous method that will return an instance of the IConnectionBrokerRequest interface.
- Wait for the hStatusEvent event to become set.
- Whenever the hStatusEvent event is set, call the IConnectionBrokerRequest::CheckStatus method to determine the status of the request.
- 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.
- Use the information in the CB_TARGET_INFO structure represented by the pTargetInfo parameter to determine where to redirect the incoming connection to.
- Release the IConnectionBrokerRequest interface.
- Close the hStatusEvent event handle, or you can reuse it for subsequent connection requests.