Skip to content

Commit 4ec5da4

Browse files
authored
Update README.md
1 parent 45a4504 commit 4ec5da4

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,38 @@ composer require ysnow/laravel-workerman
1818

1919
## 发布资源配置文件
2020
```bash
21-
php artisan vendor:publish --provider="YSnow\Laravel\Workerman\WorkermanServiceProvider"
21+
php artisan vendor:publish --provider="Ysnow\LaravelWorkerman\LaravelWorkermanServiceProvider"
2222
```
2323
## 创建监听文件 app\Events\WorkerManEvent.php
24+
回调函数参考 https://www.workerman.net/doc/workerman/worker/callbacks.html
2425
~~~
2526
<?php
27+
2628
namespace App\Events;
2729
class WorkerManEvent
2830
{
29-
public static function onConnect($client_id)
31+
public static function onMessage($client_id, $message)
3032
{
33+
return $client_id->send(json_encode(['code' => 200, 'data' => json_decode($message)]));
3134
}
32-
public static function onWebSocketConnect($client_id, $data)
35+
36+
public static function onWorkerStart()
3337
{
3438
}
35-
// 这里写自己的逻辑
36-
public static function onMessage($client_id, $message)
39+
40+
public static function onConnect($client_id)
3741
{
38-
return $client_id->send(json_encode([
39-
'code' => 200, 'data' => json_decode($message)
40-
]));;
4142
}
43+
44+
public static function onWebSocketConnect($client_id, $data)
45+
{
46+
}
47+
4248
public static function onClose($client_id)
4349
{
4450
}
4551
}
52+
4653
~~~
4754
您可以使用 Artisan 命令启动 Workerman 服务:
4855

@@ -52,11 +59,11 @@ php artisan workerman:start
5259

5360
## 示例
5461

55-
如果适用,您可以提供一些示例代码或演示来展示您的项目的功能。
62+
5663

5764
## 贡献
5865

59-
欢迎贡献!如果您想为这个项目做出贡献,请先阅读 [贡献指南](CONTRIBUTING.md)
66+
6067

6168
## 版权和许可证
6269

0 commit comments

Comments
 (0)