Laravel 事件未显示在 Websockets 仪表板上

问题描述

我试图在我的 Web 套接字仪表板上捕获一个已触发的事件,但我的事件在触发时返回 [NULL]。 请注意,它只发生在我现有的项目中。我尝试在一个新的 Laravel 项目上做同样的事情,它工作得很好。该事件在触发时返回 [](空白数组),并且该事件的内容显示在 Laravel Web 套接字仪表板中。

知道为什么在我现有的项目中返回 NULL 吗?什么可能是错误的。 下面是我的事件文件 (RealTimeMessage.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 RealTimeMessage implements Shouldbroadcast
{
    use SerializesModels;

    public $message;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->message = "Hello World";
    }
    
    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('custom-event');
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)