简体   繁体   English

JavaScript XmlHttpRequest 在 Android 上保持活动状态

[英]JavaScript XmlHttpRequest with Keep-Alive on Android

I am trying to build a website (intended to be put into a PhoneGap app) that displays messages it is sent via HTTP push (long polling, comet, ..).我正在尝试构建一个网站(旨在放入 PhoneGap 应用程序),显示通过 HTTP 推送(长轮询,彗星,..)发送的消息。 For this I need a connection that is kept alive by the client.为此,我需要一个由客户端保持活动的连接。 However, the Android browser seems to always close the connection immediately and does not allow me to set the Connection: keep-alive HTTP header.但是,Android 浏览器似乎总是立即关闭连接,并且不允许我设置 Connection: keep-alive HTTP header。

Is there a possibility to connect to the server and keep the connection alive?是否有可能连接到服务器并保持连接处于活动状态?

Thanks in advance:) MT在此先感谢:) MT

what you need is to use an implementation of some kind of HTML5 Websocket.您需要的是使用某种 HTML5 Websocket 的实现。 So far as I know, there's no direct implementation of that WebKit feature in Gingerbread 2.3.x yet, nor Phonegap but there's a workaround by library in Phonegap:据我所知,Gingerbread 2.3.x 中还没有直接实现 WebKit 功能,Phonegap 也没有,但是 Phonegap 中的库有一个解决方法:

http://anismiles.wordpress.com/2011/02/03/websocket-support-in-android%E2%80%99s-phonegap-apps/ http://anismiles.wordpress.com/2011/02/03/websocket-support-in-android%E2%80%99s-phonegap-apps/

Happy coding!快乐编码! Martin马丁

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM