提交 1322ff28 编写于 作者: crlfe's avatar crlfe 😲

Update websocket.md

上级 984acecc
...@@ -166,7 +166,7 @@ await uniCloud.ws.send(connectionId, sendData) ...@@ -166,7 +166,7 @@ await uniCloud.ws.send(connectionId, sendData)
|参数|类型|说明| |参数|类型|说明|
|---|---|---| |---|---|---|
|connectionId|`String` `Array`|客户端连接ID, 支持批量向客户端发送消息| |connectionId|`String` `Array`|客户端连接ID, 支持批量向客户端发送消息|
|sendData|`String` `Object` `Buffer`|发送给客户端的消息内容| |sendData|`String` `Buffer`|发送给客户端的消息内容|
**示例** **示例**
...@@ -182,7 +182,7 @@ exports.onWebsocketMessage = async function (event) { ...@@ -182,7 +182,7 @@ exports.onWebsocketMessage = async function (event) {
// 发送给多个客户端 // 发送给多个客户端
await uniCloud.ws.send([connectionId1, connectionId2, ...], `receive:${payload}`) await uniCloud.ws.send([connectionId1, connectionId2, ...], `receive:${payload}`)
// 发送给客户端对象数据 // 发送给客户端对象数据,发送时会自动JSON.stringify
await uniCloud.ws.send(connectionId, { await uniCloud.ws.send(connectionId, {
receive: payload receive: payload
}) })
...@@ -307,4 +307,4 @@ exampleWebSocket.onError(event => { ...@@ -307,4 +307,4 @@ exampleWebSocket.onError(event => {
console.log("WebSocket:error", event) console.log("WebSocket:error", event)
}) })
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册