且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel Echo-允许访客连接到状态频道

更新时间:2023-12-01 17:19:40

适用于任何寻求答案的人.确实可以将来宾身份验证到状态通道,而您只需要使用您自己的通道来覆盖服务提供商的Broadcast :: routes().

For anyone looking for answers to this. It is indeed possible to auth guests into presence channels you just need to override the Broadcast::routes() from the service provider with your own.

例如,我的状态频道"global"接受来宾:

As an example my presence channel 'global' accepts guests:

Route :: post('/broadcasting/auth',function(Illuminate \ Http \ Request $ req){if($ req-> channel_name =='presence-global'){返回'global';}返回abort(403);});

这可以扩展到各个方向,或者可以继续将其他状态和专用频道传递给默认的Broadcast :: auth方法

This could be extended in various directions, or could continue to pass other presence and private channels through to the default Broadcast::auth method