I am trying to write a simple firefox mobile addon that talks with my server side code using Websocket.
I have my code working for Desktop Firefox Addon but I am having difficulty with one for Firefox mobile.
function connectToServer(aWindow) {
var ws = new MozWebSocket("ws://ipaddress:8887"); // LINE 20
// var ws = new WebSocket("ws://ipaddress:8887");
ws.onopen = function() {
showToastMsg(aWindow, 'Sending');
ws.send('data');
}
ws.onmessage = function (evt) {
showToastMsg(aWindow, 'Display')
};
ws.onclose = function() {
};
I have tried both MozWebSocket and WebSocket, but both of them gives me error similar to the following :
E/GeckoConsole(15569): [JavaScript Error: "ReferenceError: MozWebSocket is not defined" {file: "resource://gre/modules/XPIProvider.jsm -> jar:file:///data/data/org.mozilla.firefox/files/mozilla/sq4c77hi.default/extensions/view-source@mydomain.org.xpi!/bootstrap.js" line: 20}]
Anyone know what I need to import or do to be able to reference WebSocket? I just want to send data back and forth from my Firefox Android addon with my server side code using websocket. Any suggestions?
I am just confused because I have this setup running on Firefox Desktop Addon with very similar code.
Any help would be very appreciated thank you!