我不能让私人频道使用推送器和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控制台中,客户端似乎没有订阅“testeevent.1”通道。如果我将此更改为公共频道,订阅将被注册。