Laravel不会将广播事件发送到推送控制台

时间:2017-11-03 09:34:53

标签: php laravel pusher

我按照此链接的说明使用推送器创建网络推送:https://blog.pusher.com/create-web-notifications-using-laravel-pusher/

但是当我试图解雇我的事件时,我无法看到我的推动仪表板调试控制台中的任何事件。

以下是我的测试的截图

Image preview

以下是一些代码

route / web.php:

Route::get('/eventtest', function () {
    event(new App\Events\StatusChanged('someone'));
    return "Event has been sent!";
});

事件类:

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class StatusChanged implements ShouldBroadcast
{
    use InteractsWithSockets, SerializesModels;

    public $message;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        // return new PrivateChannel('statusChanged');
        return ['status-changed'];
    }
}

广播配置:

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_KEY'),
            'secret' => env('PUSHER_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => 'ap1',
                'encrypted' => true
            ],
        ],

0 个答案:

没有答案