Skip to main content

HCWebSocketDisconnectFunction

Closes a WebSocket when you replace the libHttpClient WebSocket implementation. libHttpClient calls this callback when the title calls HCWebSocketDisconnect or HCWebSocketDisconnectWithStatus.

Syntax

Parameters

websocket   _In_
Type: HCWebsocketHandle
The handle of the WebSocket to close. closeStatus   _In_
Type: HCWebSocketCloseStatus
The close status to send to the peer. HCWebSocketDisconnect passes HCWebSocketCloseStatus::Normal. 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 HCWebSocketDisconnect or HCWebSocketDisconnectWithStatus.

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 invokes this callback synchronously; it has no async block. Start the close handshake and return. The close handshake itself doesn’t need to finish before the callback returns. When the connected WebSocket closes, report the closure by calling the close event function returned by HCWebSocketGetEventFunctions, passing the websocket handle and the context returned with that function. libHttpClient uses this notification to release the state that it keeps for the connection. libHttpClient calls this callback only while the WebSocket is connected. If a disconnect is already in progress, HCWebSocketDisconnect returns S_OK without calling the callback again. 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