这是我的.env配置
BROADCAST_DRIVER=pusher
PUSHER_APP_KEY=*******************
PUSHER_APP_SECRET=*********************
PUSHER_APP_ID=*****这是我的bootstrap.js
import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: '****************',
cluster: 'us2',
encrypted: true
});这是我的另一个js文件。
window.Echo.private('channel-1')
.listen('.server.created', function (e) {
alert(5)
});这是我的TestEvent文件
public function broadcastOn()
{
return new PrivateChannel('channel-1');
}
public function broadcastAs()
{
return 'server.created';
}这是我的channels.php文件
Broadcast::channel('channel-1', function ($user) {
return true;
});此外,我还为火灾事件创建了工匠命令。在我拥有文件中
event(new TestEvent());它不能在没有任何错误的情况下工作。我该怎么做??
发布于 2018-03-20 01:54:37
在event类中,您应该实现ShouldBroadcast或ShouldBroadcastNow (以防您不使用队列)。
https://stackoverflow.com/questions/46244589
复制相似问题