Connector needs to have server IP & port set directly

Everything about the SmartFoxBits UI Components for SmartFoxServer 2X. Post your questions, suggestions and bug reports.

Moderators: Bax, Lapo

Connector needs to have server IP & port set directly

Postby jonc » 01 Apr 2011, 06:30

Hi,

I'm a bit confused about the Connector control and config info.

I see there is a Connector.configPath member. I tried setting this to the config file and then calling connect(), but that fails.

It seems that I instead have to call sfs.LoadConfig() and then get the config data and stuff it into the Connector component before calling connect().

Code: Select all

public function onSFSConfigLoadSuccess( event:SFSEvent ) : void
{
    var config:ConfigData = sfs.config;
    connector.serverIpAddress = config.host;
    connector.serverPort = config.port;
    connector.connect();
}


Although this works, it makes me wonder what the point of the Connector.configPath member is. Is that only used if you are creating the component through MXML? The documentation isn't very clear on this point.
jonc
 
Posts: 18
Joined: 08 Oct 2010, 02:57

Postby Bax » 01 Apr 2011, 08:02

Setting the Connector.configPath property should be enough, causing the Connector to load the external xml file.
I'm not sure if we tested this specifically when you instantiate the Connector using AS3 instead of MXML. It might be a bug.
Can you show the code used to create the Connector?
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby jonc » 01 Apr 2011, 08:10

Here's an example of code that doesn't work (we get a connection failed event):

Code: Select all

connector = new Connector();
connector.configPath = "sfs-config.xml";
connector.connect();



The same config file works if we load it through sfs.loadConfig() and then set the connector IP address and port directly as in the code I posted above.
jonc
 
Posts: 18
Joined: 08 Oct 2010, 02:57

Postby Bax » 01 Apr 2011, 08:46

Why version of the Bits do you use? Flash or Flex?
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby jonc » 01 Apr 2011, 08:56

Flex.
jonc
 
Posts: 18
Joined: 08 Oct 2010, 02:57

Postby Bax » 01 Apr 2011, 09:04

Figured out.
The Connector relies on the cretionComplete Flex event. When this event is fired, it checks if the configPath property was set and loads the external file.

When you create the Connector using AS3 instead of MXML, the cretionComplete event is fired before you set the configPath, so it is not able to "see" the value you pass anymore.
You have to set the connection details manually.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
 
Posts: 3845
Joined: 29 Mar 2005, 09:50
Location: Italy

Postby jonc » 01 Apr 2011, 09:07

Makes sense. Thanks for looking into it Paolo.
jonc
 
Posts: 18
Joined: 08 Oct 2010, 02:57


Return to SmartFoxBits for SFS 2X

Who is online

Users browsing this forum: No registered users and 1 guest