Reputation: 1443
I am using this plugin: https://github.com/mkuklis/phonegap-websocket/*.
Unfortunately, onmessage is not called when we receive a message.
var ws = new WebSocket("ws://" + window.location.host + "" + "/my/socket");
ws.onopen = function() {
console.log("wsStatus Connected to WebSocket server!");
};
ws.onmessage = function(e) {
alert(e.data);
};
This is never called - which is bizarre because onopen is called. Is there anything specific I need to do/check - add a listener? I looked in the example code for the plugin and see the event ping
is used rather than onmessage
.
* having tried most of the options here: Phonegap websocket plugin with android version >4.0.3 not working and finding this is the only one which appears to work.
Upvotes: 0
Views: 1230
Reputation: 11707
since websocket doesnt support android<4.2, the above code fails.. you should try cross browser socket supported with fallback mode included, socket.io
link
Upvotes: 1