【发布时间】:2019-03-07 07:40:41
【问题描述】:
我无法使用 Pusher 和 Laravel 广播让私人频道工作。在routes/channels.php 文件中,似乎没有任何函数被触发:
Broadcast::channel('App.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
Broadcast::channel('testevent.{id}', function ($user, $id)
{
//This never fires
dd("ENTERED HERE");
return TRUE;
});
在BroadcastServiceProvider.php我有:
public function boot()
{
Broadcast::routes(['middleware' => 'auth:api']);
require base_path('routes/channels.php');
}
Javascript file 在客户端处理数据(使用 Echo):
Echo.private('testevent.1').listen('TestEvent', function(e)
{
console.log(e);
});
使用公共渠道非常有效。但是,一旦我尝试创建私有通道,数据就不会发送到侦听数据的客户端。可能是什么问题?
感谢您的帮助和指导!
编辑:
在 Pusher Web 控制台中,客户端似乎没有订阅“testevent.1”频道。如果我将其更改为公共频道,订阅就会被注册。
【问题讨论】: