Skip to main content

HCWebSocketSendBinaryMessageFunction

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

Syntax

Parameters

websocket   _In_
Type: HCWebsocketHandle
The handle of the connected WebSocket. payloadBytes   _In_reads_bytes_(payloadSize)
Type: const uint8_t*
The binary data to send. payloadSize   _In_
Type: uint32_t
The size of payloadBytes, in bytes. asyncBlock   _Inout_
Type: XAsyncBlock*
The async block that the title passed to HCWebSocketSendBinaryMessageAsync. 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 HCWebSocketSendBinaryMessageAsync. 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, HCWebSocketSendBinaryMessageAsync 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. Binary sends use the same identity as text sends. 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