javascript android的phonegap中的WebSocket HTML5
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15683542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WebSocket HTML5 in the phonegap for android
提问by Eldon Lesley
I'm developing an HTML5 webapp which requires to use websocket, because the webapp needs to connect to a server(websocket server), all of this time, the webapp is working fine in a desktop browser-Chrome,
我正在开发一个需要使用 websocket 的 HTML5 webapp,因为 webapp 需要连接到服务器(websocket 服务器),一直以来,webapp 在桌面浏览器 Chrome 中运行良好,
But now the web-app needs to be run in smartphones, and android will be the first priority (I don't have any experience developing android app), then I find a solution to build the web-app as an android-app using PhoneGap,
但是现在网络应用程序需要在智能手机中运行,而 android 将是首要任务(我没有任何开发 android 应用程序的经验),然后我找到了一个解决方案,将网络应用程序构建为 android-app 使用PhoneGap,
unfortunately, It doesn't support the websocket yet, I found many plugins but they all have their own server(java), what I need is a javascript library that will allow me to have the websocket run normally like it used to be in chrome, to any available ws server (I already made one in .NET using visual studio)
不幸的是,它还不支持 websocket,我找到了很多插件,但它们都有自己的服务器(java),我需要的是一个 javascript 库,它可以让我像以前在 chrome 中一样正常运行 websocket , 到任何可用的 ws 服务器(我已经使用 Visual Studio 在 .NET 中制作了一个)
any idea or reference?
任何想法或参考?
回答by Michal Kuklis
You can give https://github.com/mkuklis/phonegap-websocketa try. The demo app is here: https://bitbucket.org/mkuklis/phonegap-websocket-demo
你可以试试https://github.com/mkuklis/phonegap-websocket。演示应用程序在这里:https: //bitbucket.org/mkuklis/phonegap-websocket-demo
回答by user1226868
Websockets are not natively supported in all android browsers. My best guess is to use an Phonegap plugin for websockets.
并非所有 android 浏览器都原生支持 Websocket。我最好的猜测是为 websockets 使用 Phonegap 插件。
I suggest you take a look at https://github.com/FreakDev/PhoneGap-Android-HTML5-WebSocketor (an older) https://github.com/anismiles/websocket-android-phonegap
我建议您查看https://github.com/FreakDev/PhoneGap-Android-HTML5-WebSocket或(较旧的)https://github.com/anismiles/websocket-android-phonegap