> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HCSetWebSocketFunctions

> HCSetWebSocketFunctions

Optionally allows the caller to implement the WebSocket functions.

## Syntax

```cpp theme={null}
HRESULT HCSetWebSocketFunctions(  
         HCWebSocketConnectFunction websocketConnectFunc,  
         HCWebSocketSendMessageFunction websocketSendMessageFunc,  
         HCWebSocketSendBinaryMessageFunction websocketSendBinaryMessageFunc,  
         HCWebSocketDisconnectFunction websocketDisconnectFunc,  
         void* context  
)  
```

### Parameters

*websocketConnectFunc*   \_In\_\
Type: [HCWebSocketConnectFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketconnectfunction.md)

A callback that implements the WebSocket connect operation. This callback is required.

*websocketSendMessageFunc*   \_In\_\
Type: [HCWebSocketSendMessageFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketsendmessagefunction.md)

A callback that implements sending a text message. This callback is required.

*websocketSendBinaryMessageFunc*   \_In\_\
Type: [HCWebSocketSendBinaryMessageFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketsendbinarymessagefunction.md)

A callback that implements sending a binary message. This callback is required.

*websocketDisconnectFunc*   \_In\_\
Type: [HCWebSocketDisconnectFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketdisconnectfunction.md)

A callback that implements the WebSocket disconnect operation. This callback is required.

*context*   \_In\_opt\_\
Type: void\*

The context pointer for the callbacks.

### Return value

Type: HRESULT

Returns `S_OK` on success, `E_INVALIDARG` if any callback is `nullptr`, or `E_HC_ALREADY_INITIALISED` if libHttpClient is already initialized.

## Remarks

Call this function before [HCInitialize](https://docs.xbox.com/reference/live/httpclient/httpclient/functions/hcinitialize.md). After libHttpClient is initialized, the function returns `E_HC_ALREADY_INITIALISED`.

You must provide all four callbacks. If any callback is `nullptr`, the function returns `E_INVALIDARG`. To keep the built-in WebSocket implementation, don't call this function.

## Requirements

**Header:** httpProvider.h

**Library:** libHttpClient.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## See also

[httpProvider](https://docs.xbox.com/reference/live/httpclient/httpprovider/httpprovider_members.md)


## Related topics

- [HCWebSocketConnectFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketconnectfunction.md)
- [HCWebSocketDisconnectFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketdisconnectfunction.md)
- [HCWebSocketSendMessageFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketsendmessagefunction.md)
- [httpProvider (contents)](https://docs.xbox.com/reference/live/httpclient/httpprovider/httpprovider_members.md)
- [HCWebSocketSendBinaryMessageFunction](https://docs.xbox.com/reference/live/httpclient/httpprovider/functions/hcwebsocketsendbinarymessagefunction.md)
