Laravel echo: 频道授权
Laravel echo: channel authorization
Broadcast::channel('order.{orderId}', function ($user, $orderId) {
return $user->id === Order::findOrNew($orderId)->user_id;
});
All authorization callbacks receive the currently authenticated user as their first argument and any additional wildcard parameters as their subsequent arguments. In this example, we are using the {orderId}
placeholder to indicate that the "ID" portion of the channel name is a wildcard.
句子 All authorization callbacks receive the currently authenticated user as their first argument
对于网络广播是正确的,如果我们为移动应用程序构建广播并且移动应用程序的用户想要订阅频道怎么办?那么这个user
就不复存在了。
我们如何授权来自移动应用程序的用户?
找到了。服务器和客户端使用的协议必须相同。尽管 Laravel Echo 使用 Socket.io,但在 android 应用程序上安装 Socket.io 将无法工作。我必须在 android 上安装 LaravelEchoAndroid 软件包并使用承载令牌作为身份验证。
提示:此包存在编译错误,通过更改 maven 即可。
Broadcast::channel('order.{orderId}', function ($user, $orderId) {
return $user->id === Order::findOrNew($orderId)->user_id;
});
All authorization callbacks receive the currently authenticated user as their first argument and any additional wildcard parameters as their subsequent arguments. In this example, we are using the
{orderId}
placeholder to indicate that the "ID" portion of the channel name is a wildcard.
句子 All authorization callbacks receive the currently authenticated user as their first argument
对于网络广播是正确的,如果我们为移动应用程序构建广播并且移动应用程序的用户想要订阅频道怎么办?那么这个user
就不复存在了。
我们如何授权来自移动应用程序的用户?
找到了。服务器和客户端使用的协议必须相同。尽管 Laravel Echo 使用 Socket.io,但在 android 应用程序上安装 Socket.io 将无法工作。我必须在 android 上安装 LaravelEchoAndroid 软件包并使用承载令牌作为身份验证。
提示:此包存在编译错误,通过更改 maven 即可。