我有一個問題,我現在正在嘗試整天修復。我跟着 this教程。目標是與Laravel echo
,vue.js
和pusher
進行聊天。Laravel回聲推送器未收到廣播事件
我已經完成了一切與教程完全一樣,但由於某種原因,我沒有收到我的pusher控制檯中的任何事件。只有連接出現:
但沒有事件發生。我火災的事件是這樣的:
<?php
namespace App\Events;
use App\Message;
use App\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class MessageSent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* @var
*/
public $user;
/**
* @var
*/
public $message;
/**
* MessageSent constructor.
* @param User $user
* @param Message $message
*/
public function __construct(User $user, Message $message)
{
$this->user = $user;
$this->message = $message;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('chat');
}
}
我火了這樣的事件:
broadcast(new MessageSent($user, $message))->toOthers();
當我dd('test');
像這樣在我MessageSent事件類:
public function broadcastOn()
{
dd('test');
return new PrivateChannel('chat');
}
的dd('test');
顯示在我的網絡選項卡中。
我正在使用Laravel 5.4
和Vue.js 2.0
和Homestead
。這裏會發生什麼?!