文档更新:部分内容调整补充、WebSocket 客户端接入 (#337)

* update docs

* update docs

* update docs
This commit is contained in:
Jerry
2023-03-10 22:13:36 +08:00
committed by GitHub
parent b97cf26047
commit 799aacf292
9 changed files with 291 additions and 23 deletions

View File

@@ -382,3 +382,18 @@ public function testRoute(HttpRequestEvent $event)
快速生成一个符合 PSR-7 的 HTTP Response 对象。
有关参数,等同于 HttpFactory 对象,详见 HttpFactory 文档TODO
### ws_socket()
获取驱动的 WebSocket 操作对象。
定义:`function ws_socket(int $flag = 1): WSServerResponse`
传入一个 flag 值(值为你在 `global.php` 中为 server 设置的 flag 值),返回对应端口的 WebSocket 操作对象。
操作对象可以主动发送消息到指定客户端、可以获取指定端口的配置信息等。
```php
$socket = ws_socket();
$socket->send('hello world', $event->getFd()); // 客户端的连接 fd 编号可以通过 WebSocketOpenEvent 等事件获取
```

View File

@@ -2,7 +2,7 @@
::: danger
目前此功能还在开发中,暂不可用,预计 3.0 正式版发布后可使用
目前此功能还在开发中,暂不可用。
:::