ConfigLoader::LoadConfig can not read the file in apk

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

ganquan
Posts: 38
Joined: 17 Apr 2013, 01:42

ConfigLoader::LoadConfig can not read the file in apk

Postby ganquan » 10 May 2013, 15:33

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.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 10 May 2013, 15:37

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
Lapo
--
gotoAndPlay()
...addicted to flash games
sunny
Posts: 18
Joined: 04 Aug 2014, 04:22

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

Postby sunny » 29 Jan 2015, 02:50

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.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 29 Jan 2015, 16:23

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
Lapo

--

gotoAndPlay()

...addicted to flash games
sunny
Posts: 18
Joined: 04 Aug 2014, 04:22

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

Postby sunny » 30 Jan 2015, 03:35

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.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 30 Jan 2015, 10:01

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
Lapo

--

gotoAndPlay()

...addicted to flash games
sunny
Posts: 18
Joined: 04 Aug 2014, 04:22

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

Postby sunny » 30 Jan 2015, 12:13

great, I have found that (smartFox.Connect(config)) in C#. Thanks :D

Return to “SFS2X C++ API”

Who is online

Users browsing this forum: No registered users and 15 guests