我正在使用pusher在laravel和vuejs中开发教师和学生聊天系统。因此,正如我从文档中了解到的那样,默认情况下,laravel对私人频道和状态频道进行用户身份验证,因此我的两个模型都不同,一个是学生,另一个是老师,两者都不是从Authenticatable扩展过来的,所以我所做的就是更改authendpoint并设置新路线并返回push ath:key我成功完成此操作,但是现在问题出在返回身份验证响应之后Echo.private没有调用我的频道
这是我的Channel.php文件代码
Broadcast::channel('student-messages.{id}', function($id) {
return true;
},['guards'=>['web']]);
这是我的聊天应用程序文件代码
window.Echo.private(`student-messages.${this.student.id}`)
.listen('NewMessage',(e)=>{
console.log(e);
});
这是我在web.php中的路线
Route::post('/custom/endpoint/auth',function (Request $request){
$pusher = new Pusher\Pusher(env('PUSHER_APP_KEY'),env('PUSHER_APP_SECRET'), env('PUSHER_APP_ID'));
return $pusher->socket_auth($request->request->get('channel_name'),$request->request->get('socket_id'));
});