Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在jquery中使用适用于android的websocket_Android_Jquery_Websocket_Alert_Cordova - Fatal编程技术网

如何在jquery中使用适用于android的websocket

如何在jquery中使用适用于android的websocket,android,jquery,websocket,alert,cordova,Android,Jquery,Websocket,Alert,Cordova,嗨,在我的android应用程序中,我正在jquery中使用websocket 我尝试使用此脚本连接websocket <script src="js/jquery-1.7.2.min.js"></script> <script src="js/jquery.mobile-1.0a2.min.js"></script> <script src="js/jquery.cookie.js"></script> <scrip

嗨,在我的android应用程序中,我正在jquery中使用websocket

我尝试使用此脚本连接websocket

<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.mobile-1.0a2.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="cordova-1.8.0.js"></script>
我收到的警报是Websocket不受支持


有谁能帮我一下我的websocket编码有什么问题吗?

就像评论中提到的@Esailija一样,Android不支持websocket。查看“我可以使用”页面:


因此,尽管您希望在Android上使用web套接字,但您无法做到这一点。

Websockets与Chrome for Android v25+配合使用:

Websocket不受支持
有什么不清楚的地方?if条件if(“窗口中的Websocket”)有问题吗这个条件应该是告诉你websocket不受支持。它在android中不工作。它不受支持。我不能说得更清楚这段代码在IOS中工作正常我想在android操作系统中运行这段代码有什么问题吗
var ITOUCH_WEBSOCKET = {"remote_address":'ws://atwerervgt',"channel":'alert'};    
(function pulse(websocketDetails){
    if ("WebSocket" in window)
      {
        alert("Websocket is supported");

         // Let us open a web socket
         var ws = new WebSocket(websocketDetails.remote_address,websocketDetails.channel);

         ws.onmessage = function (evt) 
         { 

                }

                createAlert(received_msg,received_msg.actionType==='NEW');
            } else {
               // alert("Message Received : Action Type is " + received_msg.actionType);
            }


         };
         ws.onclose = function()
         { 
            // websocket is closed.
            //alert("Connection is closed...");
            // On close reconnect again
            pulse(websocketDetails);
         };
      }
      else
      {alert("Websocket is not supported");
      }
})(ITOUCH_WEBSOCKET);
    });