我创建了一个新事件,并在pusher上注册以测试我的通知。
这是我的控制器的外观:
<?php
namespace App\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 TestNotification implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $user;
public function __construct($user)
{
//
$this->user = $user;
}
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}
在TestNotification中,我初始化了构造函数:
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=database
PUSHER_APP_NAME=testapp
PUSHER_APP_ID=2655265
PUSHER_APP_KEY=ffgf5ghfgh1g5
PUSHER_APP_SECRET=6rergf4erg4er
PUSHER_APP_CLUSTER=us2
我有.env设置。 (所有细节都是假的)
List<String> list = null;
TypedQuery<String> query = sessionfactory.openSession().createQuery("from yourTableName");
list = query.getResultList();
当我访问我的URL时,用户会返回,很好,但是当我进入Pusher Console时,看不到用户数组或与通知相关的任何内容。
注意:如果我将broadcast_driver更改为登录,则它也不起作用
我可能会缺少任何东西吗?