作者 张关杰

gx

<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class WebSocketMessageSent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}
... ...
... ... @@ -7,6 +7,7 @@
"require": {
"php": "^7.4|^8.1",
"bensampo/laravel-enum": "^4.2",
"beyondcode/laravel-websockets": "^1.14",
"doctrine/dbal": "^3.6",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
... ... @@ -17,7 +18,8 @@
"laravel/tinker": "^2.5",
"mongodb/mongodb": "^1.6",
"mrgoon/aliyun-sms": "^2.0",
"phpoffice/phpspreadsheet": "^1.28"
"phpoffice/phpspreadsheet": "^1.28",
"swooletw/laravel-swoole": "^2.13"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.13",
... ...
... ... @@ -29,8 +29,11 @@ return [
*/
'connections' => [
'pusher' => [
'swoole' => [
'driver' => 'swoole',
'queue' => 'default', // 队列名
],
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
... ...