我创建了一个实现了shouldBrodcast的事件,在我的本地计算机上,Web applecation和pusher都在工作,并且正在正确执行该事件,并且正在接收API消息,但是在其他计算机上,该事件似乎并没有被执行,因为我什么也没有收到,甚至没有收到错误。
应该执行php artisan queue:listen
而不是php artisan:work
来执行shouldBrodcast
或shouldBrodcastNow
之类的东西吗?
我的活动:
<?php
namespace axv\dr\Events;
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 msgsnd implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public $msg;
private $channel_id;
public function __construct($channel_id, $msg)
{
//
$this->msg = $msg;
$this->chat_id = $channel_id;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('msging-'.$this->channel_id);
}
}
然后我将路径设置为控制器功能:
event(new msgsnd(5, 'hello'));
我没有编辑队列配置,也没有运行php artisan qeue:listen
使用本地计算机时,我在pusher调试控制台上接收到该事件,但是,在另一台计算机上,我什至没有收到一个错误。