本文介绍了Push API和服务器已发送事件之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从文档中,我可以发现 Push API 服务器发送事件都是半双工的,但是为什么两种不同的技术具有相同的功能?Push API中还有更重要的东西吗?

From the documentation I could figure out that Push API and Server Sent Events both are half duplex but why two different technologies for the same functionality?Is there something more significant in Push API?

推荐答案

即使您的站点未打开,Push API仍允许服务器向客户端发送通知,因为它依赖于服务工作者.

The Push API allows the server to send a notification to a client even when your site is not open, because it relies on service workers.

只要用户正在使用您的网站,SSE(或WebSockets)就可以正常工作.

SSE (or WebSockets) work as long as the user is using your site.

ServiceWorker食谱,可以帮助您更好地理解这一点.

There are some examples (with documentation) in the Web Push section of the ServiceWorker Cookbook that can help you understand this better.

这篇关于Push API和服务器已发送事件之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 02:22