HCWebSocketConnectFunction
Connects a WebSocket when you replace the libHttpClient WebSocket implementation. libHttpClient calls this callback when the title calls HCWebSocketConnectAsync.Syntax
Parameters
uri   _In_z_Type: const char* The UTF-8 encoded URI to connect to. subProtocol   _In_z_
Type: const char* The UTF-8 encoded subprotocol to request. websocket   _In_
Type: HCWebsocketHandle The handle of the WebSocket. Use this handle with the provider functions, such as HCWebSocketGetHeaderAtIndex, HCWebSocketGetProxyUri, and HCWebSocketGetPingInterval. asyncBlock   _Inout_
Type: XAsyncBlock* The async block for the connect operation. context   _In_opt_
Type: void* The
context value that you passed to HCSetWebSocketFunctions.
env   _In_opt_Type: HCPerformEnv An opaque value reserved for the default implementation. Ignore it.
Return value
Type: HRESULT ReturnS_OK if the connect operation started. If you return a failure code, the connect operation fails with that code.
Remarks
Register this callback, together with the other three WebSocket callbacks, by calling HCSetWebSocketFunctions before HCInitialize. HCSetWebSocketFunctions requires all four callbacks; it returnsE_INVALIDARG if any of them is nullptr.
libHttpClient reads the result of the connect operation by calling HCGetWebSocketConnectResult on asyncBlock. That function retrieves a WebSocketCompletionResult by calling XAsyncGetResult with HCWebSocketConnectAsync as the identity. Your implementation must therefore do the following:
- Call
XAsyncBeginonasyncBlockwithHCWebSocketConnectAsyncas the identity. - When the connection attempt finishes, call
XAsyncComplete(asyncBlock, hr, sizeof(WebSocketCompletionResult)). - In the
XAsyncOp::GetResultoperation, fill theWebSocketCompletionResultbuffer. Setwebsocketto thewebsocketparameter,errorCodeto the connection result, andplatformErrorCodeto a platform-specific code for diagnostics.
HC_NOWEBSOCKETS is defined.
Requirements
Header: httpProvider.h Library: libHttpClient.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consolesSee also
httpProviderHCSetWebSocketFunctions
HCGetWebSocketFunctions
