Push notification to the client browser(向客户端浏览器推送通知)
问题描述
我想创建一个应用程序,当超级用户单击链接时,用户应该收到通知,或者更确切地说是 pdf 等内容,供他们在屏幕上访问.
I'd like to create an application where when a Super user clicks a link the users should get a notification or rather a content like a pdf for them to access on the screen.
用例:当教师想要与他的学生共享 PDF 时,他应该能够通知他的学生可以下载的 pdf,并且必须提供一个链接来执行相同的操作.
Use Case: When a teacher wants to share a PDF with his students he should be able to notify his students about the pdf available for download and a link has to be provided to do the same.
推荐答案
因为你想在 CakePHP 中实现它(所以我假设它是一个基于 Web 的应用程序),用户必须在以接收推送消息.
As you want to implement this in CakePHP (so I assume it's a web-based application), the user will have to have an 'active' page open in order to receive the push messages.
值得一看前两个答案,但也要考虑其他网站如何实现这一点.Facebook、BBC、Stackoverflow 等网站都使用技术来使页面保持最新.
It's worth looking at the first two answers to this, but also just think about how other sites might achieve this. Sites like Facebook, BBC, Stackoverflow all use techniques to keep pages up to date.
我怀疑 Facebook 只是使用了一些在循环/计时器中运行的 AJAX,以使其看起来像推送的方式定期拉取更新.如果更新请求足够频繁(短时间段),它看起来几乎是实时的.如果时间很长,它看起来像拉动.在更新和浏览器/处理器/网络抖动之间找到适当的平衡是关键.
I suspect Facebook just uses some AJAX that runs in a loop/timer to periodically pull updates in a way that would make it look like push. If the update request is often enough (short time period), it'll almost look realtime. If it's a long time period it'll look like a pull. Finding the right balance between up-to-dateness and browser/processor/network thrashing is the key.
实际请求不应该影响系统,但某些应用程序中的回复可能要大得多.在您的情况下,每个方向的数据都很小,因此您可以使请求循环非常短.
The actual request shouldn't thrash the system, but the reply in some applications may be much bigger. In your case, the data in each direction is tiny, so you could make the request loop quite short.
实验!
这篇关于向客户端浏览器推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:向客户端浏览器推送通知


- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01