question about loadConfig

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

Post Reply
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

question about loadConfig

Post by pantinor »

Is it possible to load config using a resource URL instead of a filename? I have the app and xml in a jar file and want to use the class.getResource style of loading it.

Otherwise, can i skip loading from external XML and just set the connection props directly in API?

Thanks.
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Post by A51Integrated »

Sure can. Just read through the docs for sfs2x.client.util.ConfigData. There are setters for all parameters.

Then call SmartFox.connect() directly.
A51 Integrated
http://a51integrated.com / +1 416-703-2300
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

Post by pantinor »

I am getting a null value when doing this below. Why is that? It seems like a catch 22 if you need to call loadConfig on a xml that is not there. It seems like we don't support anything except using an xml file.

ConfigData cfg = sfs.getConfig();
cfg.setHost(serverIPTextField.getText());
cfg.setUdpHost(serverIPTextField.getText());
cfg.setPort(9933);
cfg.setUdpPort(9933);
pantinor
Posts: 17
Joined: 19 Jan 2012, 02:10

Post by pantinor »

I was able to connect by doing this directly.

sfs.connect(serverIPTextField.getText(),9933);


Followed by sending the client loginrequest with the name and zone parameters.

I could not find any use for the ConfigData object. Even when creating a new ConfigData object explicitly.

The problem is after the connect, there is only the HANDSHAKE event from the server. There is no LOGIN of CONNECTION events fired despite registering for the callbacks on those events. The smartfox log shows a successful login.

Seems like some things are missing here.
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Post by A51Integrated »

The fact that it only connects is by design. That's all it should do. Once you receive the onConnection event, you will then have to manually login to a zone.
A51 Integrated
http://a51integrated.com / +1 416-703-2300
Post Reply