当浏览器在后台时,SSE 和 Websockets 是否工作? [英] Do SSE and Websockets work when the browser is in the background?

查看:49
本文介绍了当浏览器在后台时,SSE 和 Websockets 是否工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SSE(服务器发送事件)Websockets 允许从服务器到客户端的实时消息传递.

Both SSE (Server Sent events) and Websockets allow real-time messaging from a server to a client.

当浏览器处于后台并且其他程序处于焦点时,这些流协议是否有效,尤其是在移动浏览器中?

Do these stream protocol work when the browser is in the background and another programs are in focus, especially in mobile browsers?

推荐答案

是的.至少是 WebSocket.

Yes. At least WebSocket.

在浏览器 1 中打开这个 demo,点击打开第二个实例",将链接复制到浏览器2,将浏览器1置于后台,然后在浏览器2中点击发布".

Open this demo in browser 1, click on "open 2nd instance", copy the link to browser 2, put browser 1 to background and click "publish" in browser 2.

该演示也适用于移动版 Chrome(Android 版).我刚刚测试过:它会收到消息 a) 切换到另一个标签时,然后切换回来,以及 b) 如果您打开另一个活动(应用程序),然后返回 Chrome.

The demo will work on Chrome for Mobile (on Android) also. I have just tested: it'll receive messages a) when switching to another tab, and then switch back, and also b) if you open another activity (app), and then return to Chrome.

您也可以尝试其他演示.除了带有beatbox 演示"的音频输出之外,一切都可以在 Chrome Mobile 上运行.请注意,使用beatbox 演示",您仍然可以将智能手机用作控制器......只是音频输出有问题.

You can also try the other demos. Other than audio output with the "beatbox demo", everything will work on Chrome Mobile. Note that with the "beatbox demo", you can still use the smartphone as a controller .. it's just the audio output which has issues.

免责声明:我是 Crossbar.io 的原作者,并为 Tavendo 工作.

Disclaimer: I am original author of Crossbar.io and work for Tavendo.

这篇关于当浏览器在后台时,SSE 和 Websockets 是否工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆