# Function: connectSocket
▸ connectSocket(params
: ConnectSocketParams): Promise‹ConnectSocketRes› & SocketTask
创建一个 WebSocket 连接。使用前请注意阅读{@link 相关说明 (opens new window)}。
todo
update doc link above
# 参数:
属性 | 类型 |
---|---|
params | ConnectSocketParams |
ConnectSocketParams
属性 | 类型 | 描述 |
---|---|---|
header? | Record‹string, unknown› | HTTP Header,Header 中不能设置 Referer |
perMessageDeflate? | boolean | 是否开启压缩扩展 |
protocols? | string[] | 子协议数组 |
tcpNoDelay? | boolean | 建立 TCP 连接的时候的 TCP_NODELAY 设置 |
timeout? | number | 超时时间,单位为毫秒 |
url | string | 开发者服务器 wss 接口地址 |
complete? | Method | 接口调用结束的回调函数(调用成功、失败都会执行) |
fail? | Method | 接口调用失败的回调函数 |
success? | Method | 接口调用成功的回调函数 |
# 返回值:
Promise‹ConnectSocketRes› & SocketTask