0

Hi !

Let's get directly to the problem :

I'm actually doing a firefox extension in which i would like to implement the jWebsocket API in order to build a small chat.
I got my main script file, named test.js, and the jWebsocket lib into a js folder.
Just for you to know, this is my first firefox extension ever.

So in my XUL file I got this :

....
<overlay id="test-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
		<script type="application/x-javascript" src="chrome://test/content/test.js" />
		<script type="application/x-javascript" src="chrome://test/content/js/jwebsocket.js" />
....

jwebsocket.js being the file I need to call according to jWebsocket website.

In my main script file test.js I start with :

//Check WebSocket/FlashBridge support
if (jws.browserSupportsWebSockets()) 
{
  jWebSocketClient = new jws.jWebSocketJSONClient();
} 
else 
{
  var lMsg = jws.MSG_WS_NOT_SUPPORTED;
  alert(lMsg);
}
 
var lURL = "ws://localhost:8787";
var gUsername = "TestUser";
var lPasswort = "";

//log("Connecting to " + lURL + " and logging in as '" + gUsername + "'..." );
var lRes = jWebSocketClient.logon( lURL, gUsername, lPassword, {
  // OnOpen callback
  OnOpen: function( aEvent ) 
  {
    //log("jWebSocket connection established");
  },
  // OnMessage callback
  OnMessage: function( aEvent, aToken ) 
  {
    //log("jWebSocket '" + aToken.type + "' token received, full message: '" + aEvent.data);
  },
  // OnClose callback
  OnClose: function( aEvent ) 
  {
    //log("jWebSocket connection closed." );
  }
});

...

jws being the namespace created into the jwebsocket.js file.

Of course I've got the required stand-alone server running in background, and working.

So from what I understood looking on various websites, is that if a js file is loaded into the javascript allocated space (with the <script> tag), all namespace/function should be available between each file. But this was mostly for HTML-oriented issues, so I'm not sure if it applies to XUL/Firefox environment.

But the script keep failing at the first jws call.

Any ideas on what goes wrong here ? I'm stuck for 2 days now :/

1
Contributor
1
Reply
3
Views
7 Years
Discussion Span
Last Post by colon3l
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.