-1

こんにちは、私の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 に接続するために使用したコードです

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);
    });      

私が受け取っているアラートは Websocket is not supported です

私のwebsocketコーディングの問題は何ですか?

4

2 に答える 2

0

コメントで言及されている@Esailijaと同様に、WebSocketはAndroidではサポートされていません。「使用できますか」ページをご覧ください。

http://caniuse.com/#feat=websockets

したがって、AndroidでWebソケットを使用したい限り、それを使用することはできません。

于 2012-06-21T14:00:22.193 に答える
0

Websockets は Chrome for Android v25 以降で動作します: http://caniuse.com/websockets

于 2013-05-02T09:27:02.873 に答える