Connect manually using sails.io.js

I am trying to use sails.io.js in the chrome extension.

I manually set the URL of my sail server using the line:

io.sails.url = "http://localhost:1337";

But I would like to get the url from chrome local storage (to save the url not directly in the code). But the problem is here here :

After import, you get 1 clock after importing the connection.

So, if I get the url from chrome local storage using

storage.get('url', function(result){
    var url = result.url;
    io.sails.url = url ;
});

It's too late! Parameters must be set immediately after the sails.io.js code ..

So, I was thinking of disabling autoConnect with

io.sails.autoConnect = false;

(As said there )

But now my question is: how can I connect manually using io.sails?

I tried io.sails.connect (), did not work. Any ideas?

Many thanks,

+4
1

, , sails.io.js,

  • setTimeout io.sails.doit = function() {
  • io.sails.autoConnect
  • io.sails.doit(..),

, - , {'query':'param='+value} io.connect(io.sails.url); sails app config/sockets.js socket.handshake.query.param.

+1

All Articles