Php 拉威尔回声没有任何反应

Php 拉威尔回声没有任何反应,php,laravel,pusher,laravel-echo,Php,Laravel,Pusher,Laravel Echo,我有一个引导模式。当模式打开时,我想将用户添加到“队列”中。当模式关闭时,我想将它们从所述队列中移除。如果他们离开页面等,也应将他们从队列中删除 这就是我所做的 已配置.env: BROADCAST_DRIVER=pusher PUSHER_APP_ID=(i put my app id here) PUSHER_APP_KEY=(i put my app key here) PUSHER_APP_SECRET=(i put my app secret here) PUSHER_APP_CLU

我有一个引导模式。当模式打开时,我想将用户添加到“队列”中。当模式关闭时,我想将它们从所述队列中移除。如果他们离开页面等,也应将他们从队列中删除

这就是我所做的

已配置
.env

BROADCAST_DRIVER=pusher

PUSHER_APP_ID=(i put my app id here)
PUSHER_APP_KEY=(i put my app key here)
PUSHER_APP_SECRET=(i put my app secret here)
PUSHER_APP_CLUSTER=us2
我在
config.App
中取消注释了
App\Providers\BroadcastServiceProvider::class,

将频道添加到
路由/频道

Broadcast::channel('queue', function (\App\User $user) {
    return $user->toArray();
});
创建我的事件类:

class QueueJoined implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $user;

    public function __construct(User $user)
    {
        $this->user = $user;
    }

    public function broadcastOn()
    {
        return new PresenceChannel('queue');
    }
}

class QueueLeft implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $user;

    public function __construct(User $user)
    {
        $this->user = $user;
    }

    public function broadcastOn()
    {
        return new PresenceChannel('queue');
    }
}
添加了我的脚本(我正在使用laravel livewire):

我现在也在运行
php artisan queue:listen

广播没有任何效果。Pusher甚至显示0个连接。我也没有在Laravel错误日志或Chrome控制台中得到任何错误


我不确定我在这里做错了什么,因此我们非常感谢您的帮助。

您是否实例化了Echo对象?请参阅
window.Echo=new Echo({broadcaster:'pusher',key:'your pusher channels key'})是,我已经实例化了它。其他用户是否正确加入和离开频道?只有当其他用户加入或离开频道时,才会触发您订阅的事件。您可以尝试绑定到
here
事件,以检查订阅时出现的用户。最后,您在Pusher调试控制台中看到任何活动了吗?
<script>
    window.livewire.on('show-modal', () => {
        $('#queue-modal').modal('show');
        console.log('show-modal'); // called

        Echo.join('queue')
            .joining((user) => {
                window.livewire.call('joining-queue');
                console.log('joining: ' + user.name); // not called
            })
            .leaving((user) => {
                window.livewire.call('leaving-queue');
                console.log('leaving: ' + user.name); // not called
            })
            .listen('QueueJoined', (e) => {
                console.log('QueueJoined: ' + e.user.name); // not called
            })
            .listen('QueueLeft', (e) => {
                console.log('QueueLeft: ' + e.user.name); // not called
            });
    });
    window.livewire.on('hide-modal', () => {
        $('#queue-modal').modal('hide');
        console.log('hide-modal'); // called

        Echo.leave('queue');
    });
</script>
class Queue extends Component
{
    public $message;

    public function render()
    {
        return view('livewire.queue');
    }

    public function showModal()
    {
        $this->message = 'Joining queue...';
        $this->emit('show-modal');
    }

    public function hideModal()
    {
        $this->message = 'Leaving queue...';
        $this->emit('hide-modal');
    }

    public function joiningQueue()
    {
        $this->message = 'Queue joined! Finding match...';
        // add to queue table
        broadcast(new QueueJoined(Auth::user()));
    }

    public function leavingQueue()
    {
        $this->message = 'Queue left.';
        // remove from queue table
        broadcast(new QueueLeft(Auth::user()));
    }
}