Config loading on android

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Demvamko
Posts: 2
Joined: 05 Jul 2016, 11:18

Config loading on android

Postby Demvamko » 05 Jul 2016, 11:31

Hey everyone! We have been working on an android game for some time and have recently started compiling the builds. Unfortunately we cant load SmartFox config on our devices for some reason. We use the usuall

Code: Select all

"sfs.LoadConfig (Application.dataPath + "/" + remoteConfigFile);"

This has been causing us some troubles, i have redirected the connect to

Code: Select all

void OnConfigFail(BaseEvent e) { sfs.Connect("xxx.xxx.xxx.xxx", xxxx); }

but for some reason we still have certain problems at some parts of the code (our client side sfs code was written by another developer on our team)
So my Question is: How do i load config file on an android? And is there a way to bypass it? (like making a config object then assigning it)
Note that sfs.LoadConfig(); returns a null reference (shouldnt it create a default or something?)
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Config loading on android

Postby Lapo » 05 Jul 2016, 13:26

Hi,
yes you can totally bypass the external config and use the ConfigData class, which exposes the same properties of the config file.

Example:

Code: Select all

ConfigData cfg = new ConfigData();
cfg.setHost("my.website.com");
cfg.setPort(9933);
cfg.setUseBBox(true);
cfg.setZone("MyGameZone");
cfg.setDebug(true);

sfs.connect(cfg);


hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Demvamko
Posts: 2
Joined: 05 Jul 2016, 11:18

Re: Config loading on android

Postby Demvamko » 05 Jul 2016, 22:10

Well perhaps not. I myself am not sure of what really causes the problem. We suspect it could be because SmartFox.Config property isn't properly initialized. I might have to re-read the whole code, until then is there any function in the API that relies on SmartFox.Config in any way? Thanks for the reply anyway :D
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Config loading on android

Postby Lapo » 06 Jul 2016, 06:12

Hi,
a configuration must exist before you try to connect. You can either load it from an external (xml) file or create it yourself from code.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 24 guests