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

# HCSetWebSocketFunctions

> HCSetWebSocketFunctions

# HCSetWebSocketFunctions

可选地允许调用方实现 WebSocket 函数。

## Syntax

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

### Parameters

*websocketConnectFunc*   \_In\_\
Type: HCWebSocketConnectFunction

按需实现 WebSocket connect 函数的回调。传入 nullptr 可使用基于当前平台的默认实现。

*websocketSendMessageFunc*   \_In\_\
Type: HCWebSocketSendMessageFunction

按需实现 WebSocket send message 函数的回调。传入 nullptr 可使用基于当前平台的默认实现。

*websocketSendBinaryMessageFunc*   \_In\_\
Type: HCWebSocketSendBinaryMessageFunction

按需实现 WebSocket send binary message 函数的回调。传入 nullptr 可使用基于当前平台的默认实现。

*websocketDisconnectFunc*   \_In\_\
Type: HCWebSocketDisconnectFunction

按需实现 WebSocket disconnect 函数的回调。传入 nullptr 可使用基于当前平台的默认实现。

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

回调的上下文指针。

### Return value

Type: HRESULT

此 API 操作的结果代码。可能的值为 S\_OK 或 E\_FAIL。

## Requirements

**Header:** httpProvider.h

**Library:** libHttpClient.GDK.lib

## See also

[httpProvider](/reference/live/httpclient/httpprovider/httpprovider_members)


## Related topics

- [HCWebSocketSetHeader](/zh-CN/reference/live/httpclient/httpclient/functions/hcwebsocketsetheader.md)
- [HCWebSocketSetProxyUri](/zh-CN/reference/live/httpclient/httpclient/functions/hcwebsocketsetproxyuri.md)
- [HCWebSocketSetBinaryMessageFragmentEventFunction](/zh-CN/reference/live/httpclient/httpclient/functions/hcwebsocketsetbinarymessagefragmenteventfunction.md)
- [HCWebSocketSetProxyDecryptsHttps](/zh-CN/reference/live/httpclient/httpclient/functions/hcwebsocketsetproxydecryptshttps.md)
- [HCWebSocketSetMaxReceiveBufferSize](/zh-CN/reference/live/httpclient/httpclient/functions/hcwebsocketsetmaxreceivebuffersize.md)
