laravel - PresenceChannels 和 PrivateChannels 之间的区别是什么 - LARAVEL 5.8

标签 laravel

我在我的 laravel 应用程序上运行 socket.iolaravel-echo-server。所以我想知道 privateChannelspresenceChannels 之间的区别。我觉得在很多情况下(如果不是全部)它们可以互换使用。

例如在我的应用中:

  • 有些情况下我需要通知所有用户 部门。
  • 然后在某些情况下我需要通知某些特定的人 在部门内具有特定权限的用户。
  • 那么在某些情况下我可能需要提供一些 用户临时访问某些通知等。

最佳答案

来自official documentation :

Presence channels build on the security of private channels while exposing the additional feature of awareness of who is subscribed to the channel. This makes it easy to build powerful, collaborative application features such as notifying users when another user is viewing the same page.

换句话说,存在 channel 本身也是私有(private) channel ,但允许每个用户看到同一 channel 中的其他用户。常见的示例是带有房间的聊天应用程序,其中每个房间都是一个 channel 。

对于您描述的场景,我希望始终使用私有(private) channel 。您的描述读起来好像该应用程序受身份验证保护,这会自动排除公共(public) channel 。由于您也不要求您的用户查看还有谁收到了通知(至少您没有提到),因此存在 channel 没有意义。这让我们可以选择使用私有(private) channel 。

关于laravel - PresenceChannels 和 PrivateChannels 之间的区别是什么 - LARAVEL 5.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56970270/

相关文章:

php - MySQL 语法错误 : ORDER BY clause is not in GROUP BY

php - 一直使用 Laravel Eloquent?

php - 如何仅在 laravel 中使用 DATE 获取数据?

laravel - 按关系值对集合进行排序

javascript - 我如何在 Vuejs 中设置刷新时的旧输入值

php - Laravel - Mongodb [jenssegers/laravel-mongodb] - 架构生成器

php - Laravel/Eloquent - 列名作为变量

php - Laravel Eloquent 中的多表继承

laravel - 如何在 Laravel 上的电子邮件布局中显示图像?

php - Laravel - 首先从数据库中获取特定行