Skip to content

Commit

Permalink
修正
Browse files Browse the repository at this point in the history
yunwuxin committed Jan 19, 2025
1 parent 944f515 commit 19fb7bb
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ return [
#### 配置

```
swoole.websocket = true 时开启
worker.websocket = true 时开启
```

#### 路由定义
@@ -92,15 +92,14 @@ Route::get('path2','controller/action2');
#### 控制器

```php
use \think\swoole\Websocket;
use \think\swoole\websocket\Event;
use \Swoole\WebSocket\Frame;
use \think\worker\Websocket;
use \think\worker\websocket\Frame;

class Controller {

public function action1(){

return \think\swoole\helper\websocket()
return (new \think\worker\response\Websocket())
->onOpen(...)
->onMessage(function(Websocket $websocket, Frame $frame){
...
@@ -110,7 +109,7 @@ class Controller {

public function action2(){

return \think\swoole\helper\websocket()
return (new \think\worker\response\Websocket())
->onOpen(...)
->onMessage(function(Websocket $websocket, Frame $frame){
...
2 changes: 1 addition & 1 deletion src/websocket/socketio/Handler.php
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ public function onOpen(Request $request)

$this->push(EnginePacket::open($payload));

$this->event->trigger('swoole.websocket.Open', $request);
$this->event->trigger('worker.websocket.Open', $request);

if ($this->eio < 4) {
$this->resetPingTimeout($this->pingInterval + $this->pingTimeout);

0 comments on commit 19fb7bb

Please sign in to comment.