正在显示
3 个修改的文件
包含
44 行增加
和
3 行删除
app/Events/WebSocketMessageSent.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Events; | ||
| 4 | + | ||
| 5 | +use Illuminate\Broadcasting\Channel; | ||
| 6 | +use Illuminate\Broadcasting\InteractsWithSockets; | ||
| 7 | +use Illuminate\Broadcasting\PresenceChannel; | ||
| 8 | +use Illuminate\Broadcasting\PrivateChannel; | ||
| 9 | +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
| 10 | +use Illuminate\Foundation\Events\Dispatchable; | ||
| 11 | +use Illuminate\Queue\SerializesModels; | ||
| 12 | + | ||
| 13 | +class WebSocketMessageSent | ||
| 14 | +{ | ||
| 15 | + use Dispatchable, InteractsWithSockets, SerializesModels; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * Create a new event instance. | ||
| 19 | + * | ||
| 20 | + * @return void | ||
| 21 | + */ | ||
| 22 | + public function __construct() | ||
| 23 | + { | ||
| 24 | + // | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * Get the channels the event should broadcast on. | ||
| 29 | + * | ||
| 30 | + * @return \Illuminate\Broadcasting\Channel|array | ||
| 31 | + */ | ||
| 32 | + public function broadcastOn() | ||
| 33 | + { | ||
| 34 | + return new PrivateChannel('channel-name'); | ||
| 35 | + } | ||
| 36 | +} |
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | "require": { | 7 | "require": { |
| 8 | "php": "^7.4|^8.1", | 8 | "php": "^7.4|^8.1", |
| 9 | "bensampo/laravel-enum": "^4.2", | 9 | "bensampo/laravel-enum": "^4.2", |
| 10 | + "beyondcode/laravel-websockets": "^1.14", | ||
| 10 | "doctrine/dbal": "^3.6", | 11 | "doctrine/dbal": "^3.6", |
| 11 | "fruitcake/laravel-cors": "^2.0", | 12 | "fruitcake/laravel-cors": "^2.0", |
| 12 | "guzzlehttp/guzzle": "^7.0.1", | 13 | "guzzlehttp/guzzle": "^7.0.1", |
| @@ -17,7 +18,8 @@ | @@ -17,7 +18,8 @@ | ||
| 17 | "laravel/tinker": "^2.5", | 18 | "laravel/tinker": "^2.5", |
| 18 | "mongodb/mongodb": "^1.6", | 19 | "mongodb/mongodb": "^1.6", |
| 19 | "mrgoon/aliyun-sms": "^2.0", | 20 | "mrgoon/aliyun-sms": "^2.0", |
| 20 | - "phpoffice/phpspreadsheet": "^1.28" | 21 | + "phpoffice/phpspreadsheet": "^1.28", |
| 22 | + "swooletw/laravel-swoole": "^2.13" | ||
| 21 | }, | 23 | }, |
| 22 | "require-dev": { | 24 | "require-dev": { |
| 23 | "barryvdh/laravel-ide-helper": "^2.13", | 25 | "barryvdh/laravel-ide-helper": "^2.13", |
| @@ -29,8 +29,11 @@ return [ | @@ -29,8 +29,11 @@ return [ | ||
| 29 | */ | 29 | */ |
| 30 | 30 | ||
| 31 | 'connections' => [ | 31 | 'connections' => [ |
| 32 | - | ||
| 33 | - 'pusher' => [ | 32 | + 'swoole' => [ |
| 33 | + 'driver' => 'swoole', | ||
| 34 | + 'queue' => 'default', // 队列名 | ||
| 35 | + ], | ||
| 36 | + 'pusher' => [ | ||
| 34 | 'driver' => 'pusher', | 37 | 'driver' => 'pusher', |
| 35 | 'key' => env('PUSHER_APP_KEY'), | 38 | 'key' => env('PUSHER_APP_KEY'), |
| 36 | 'secret' => env('PUSHER_APP_SECRET'), | 39 | 'secret' => env('PUSHER_APP_SECRET'), |
-
请 注册 或 登录 后发表评论