Mozilla Support में खोजें

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

How to use Websocket for Firefox for Mobile Android Addon

  • 1 प्रत्युत्तर दें
  • 2
  • 1 view
  • के द्वारा अंतिम प्रतियुतर iamjayakumars

more options

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.

I have a short code written at https://bitbucket.org/ykim320/kayo. The desktop firefox extension works fine. But I have having trouble getting mobile version of addon to send message and connect to server. If you have anyway you can connect to the server using firefox mobile addon any pointers will be appreciated. Thank you again.

Any help would be very appreciated thank you!

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. I have a short code written at https://bitbucket.org/ykim320/kayo. The desktop firefox extension works fine. But I have having trouble getting mobile version of addon to send message and connect to server. If you have anyway you can connect to the server using firefox mobile addon any pointers will be appreciated. Thank you again. Any help would be very appreciated thank you!

All Replies (1)

more options

Ask your Problem in Addons developer forum