Page 1 of 1

ConfigLoader::LoadConfig can not read the file in apk

Posted: 10 May 2013, 15:33
by ganquan
i try to run my cocos2dx game with api 0.9.5 on android, which work fine on iOS and win7, but it crash on android.
and i found, in ConfigLoader::LoadConfig, using ifstream to open read file.
my sfs-config.xml is in the assets, which pack into apk with other resource, and ifstream can not read the file in apk.

use cocos2dx CCFileUtils getFileData instead, the game works.

Re: ConfigLoader::LoadConfig can not read the file in apk

Posted: 10 May 2013, 15:37
by Lapo
You can avoid loading an external file from the APK package and connect directly by passing the IP address and port of the server.
Thanks

Re: ConfigLoader::LoadConfig can not read the file in apk

Posted: 29 Jan 2015, 02:50
by sunny
If I connect to the server by the following code without loading config xml file, will bluebox be started in the client side?
smartfox.Connect("server ip", 9933);

At the same time, should i set the httpPort?
If i should set it, how can I set in the code? Thanks.

Re: ConfigLoader::LoadConfig can not read the file in apk

Posted: 29 Jan 2015, 16:23
by Lapo
You can configure the connection parameter using the ConfigData class.
It contains the same settings that the external XML file uses, but this way you can do everything in code. Then you can call connect passing the ConfigData instance.

If I connect to the server by the following code without loading config xml file, will bluebox be started in the client side?
smartfox.Connect("server ip", 9933);

Yes by default the BlueBox connection is active.

At the same time, should i set the httpPort?

By default port 8080 is used. If you're running the SmartFox's http server on a different port you will need to specify it in the client config, otherwise the default will be used.

Cheers

Re: ConfigLoader::LoadConfig can not read the file in apk

Posted: 30 Jan 2015, 03:35
by sunny
Thanks for the reply.

We are using SmartFox 2X Client API C# 1.5.6. There is no ConfigData class. It also don't have connectWithConfig(cfg:ConfigData):void method.

Luckily we are using the default 8080 http port.

Re: ConfigLoader::LoadConfig can not read the file in apk

Posted: 30 Jan 2015, 10:01
by Lapo
Then this is the wrong section :) This is C++ not C#

Anyways: in the C# API version 1.5.6 there certainly is a class Sfs2X.Util.ConfigData, and a method SmartFox.Connect(ConfigData cf)

Please make sure your using ... declaration at the top of your code are correct.

Thanks

Re: ConfigLoader::LoadConfig can not read the file in apk

Posted: 30 Jan 2015, 12:13
by sunny
great, I have found that (smartFox.Connect(config)) in C#. Thanks :D