Skip to main content

HCWebSocketSendMessageFunction

Sends a text message on a WebSocket when you replace the libHttpClient WebSocket implementation. libHttpClient calls this callback when the title calls HCWebSocketSendMessageAsync.

Syntax

Parameters

websocket   _In_
Type: HCWebsocketHandle
The handle of the connected WebSocket. message   _In_z_
Type: const char*
The UTF-8 encoded text message to send. asyncBlock   _Inout_
Type: XAsyncBlock*
The async block that the title passed to HCWebSocketSendMessageAsync. context   _In_opt_
Type: void*
The context value that you passed to HCSetWebSocketFunctions.

Return value

Type: HRESULT libHttpClient returns this value to the caller of HCWebSocketSendMessageAsync. Return S_OK if the send operation started.

Remarks

Register this callback, together with the other three WebSocket callbacks, by calling HCSetWebSocketFunctions before HCInitialize. HCSetWebSocketFunctions requires all four callbacks; it returns E_INVALIDARG if any of them is nullptr. libHttpClient calls this callback only while the WebSocket is connected. Otherwise, HCWebSocketSendMessageAsync returns E_UNEXPECTED without calling the callback. The title gets the result by calling HCGetWebSocketSendMessageResult, which calls XAsyncGetResult with HCWebSocketSendMessageAsync as the identity and a WebSocketCompletionResult buffer. Your implementation must therefore begin the operation on asyncBlock by calling XAsyncBegin with HCWebSocketSendMessageAsync as the identity, complete it with XAsyncComplete(asyncBlock, hr, sizeof(WebSocketCompletionResult)), and fill the result in the XAsyncOp::GetResult operation. This callback type isn’t declared when HC_NOWEBSOCKETS is defined.

Requirements

Header: httpProvider.h Library: libHttpClient.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consoles

See also

httpProvider
HCSetWebSocketFunctions
HCGetWebSocketFunctions
Last modified on October 30, 2026