Skip to content

Commit

Permalink
update cn doc (#976)
Browse files Browse the repository at this point in the history
update cn doc for pr #968

Co-authored-by: redsun <jinxueli@imooc.com>
  • Loading branch information
redsun and redsun committed May 5, 2024
1 parent 902c973 commit 3a22dab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/advanced/websockets.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WebSockets

[WebSockets](https://zh.wikipedia.org/wiki/WebSocket) 允许客户端和服务器之间进行双向通信。与 HTTP 的请求和响应模式不同,WebSocket 可以在两端之间发送任意数量的消息。Vapor的WebSocket API允许你创建异步处理消息的客户端和服务器
[WebSockets](https://zh.wikipedia.org/wiki/WebSocket) 允许客户端和服务器之间进行双向通信。与 HTTP 的请求和响应模式不同,WebSocket 可以在两端之间发送任意数量的消息。Vapor 的 WebSocket API 允许你创建异步处理消息的客户端和服务器

## 服务器

Expand Down Expand Up @@ -58,6 +58,12 @@ promise.futureResult.whenComplete { result in
}
```

如果使用 `async`/`await`,你可以使用 `await` 来等待异步操作完成。

```swift
try await ws.send(...)
```

### 接收

接收的消息通过 `onText``onBinary` 回调进行处理。
Expand Down

0 comments on commit 3a22dab

Please sign in to comment.