Error on Connection

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

Moderators: Lapo, Bax

Posts: 8
Joined: 14 Apr 2008, 15:34

Error on Connection

Postby cristianpark » 26 Jul 2012, 17:11

Hi guys, I'm starting using SFS for Android

I can execute the Connector example and connect to my SFS Server but I find the code too overload and want to make one on my own that is less complex. I have an Activity with server IP input and a Button to connect to the server and fire logs from the methods (I will send to another activity when the code work).

I'm having error output on LogCat (log.txt attached) and I want to know what can cause the problem. The last log (from the ones I fire) I recognize is:

Code: Select all

07-26 11:49:16.147: D/CR-Conectar(5290): Se va a conectar al servidor

followed by:

Code: Select all

07-26 11:49:16.225: W/System.err(5290): 5366 [New I/O client worker #1-1] INFO sfs2x.client.core.EventDispatcher - Dispatching event OnConnect to 1 listeners
07-26 11:49:16.225: W/System.err(5290): 5367 [New I/O client worker #1-1] INFO sfs2x.client.core.EventDispatcher - Dispatching event connect to 1 listeners
[b]07-26 11:49:16.241: E/dalvikvm(5290): Could not find class 'net.sf.json.JSONObject', referenced from method com.smartfoxserver.v2.protocol.serialization.DefaultSFSDataSerializer.decodeJsonObject[/b]

So I think the error is JSON related but I don't know how to solve it

Can you help me please? This [1] is my app source code if you want to get into the guts of it

Thanks in advance

LogCat output
(2.43 KiB) Downloaded 156 times
Posts: 8
Joined: 14 Apr 2008, 15:34

Re: Error on Connection

Postby cristianpark » 30 Jul 2012, 20:52

Hi guys, the problem was fixed after copy the .jar files from SFS package, I think you should remove the libs from the examples like a way of forcing users to copy the latests versions from the package (I know you enfatize on that in the tutorial but as I see is a common mistake)

As I can go further with the example, I came out with a basic chat app that I like to share with you [1]. The app workflow is:
- Connect to a server (a spinner defines options for common server IP's)
- Use a custom login extension which validate against PostgreSQL server. Database name must be batallan if you want to try the examples as it comes (really all you need is a database called batallan and a table called btnusuario with two fields btnusuario_login, btnusuario_password -MD5 hash-)
- Login into "BatallaNaval" zone and join on "Juego" room (you must create them or change for your particular needs). Note: before the password is sent for the login, it's MD5 hashed (for making it match with DB password)
- When the user joins the room, the app chooses a random color and assign it to him (user variable)
- When another user talks to you, the phone vibrates and you see the user nick with the color assigned by the server

Pretty much, that's it. The user interface is precarious as consists in two layouts showed/hidded on demand, I want to focus on server connection functionality and giving starters (as I) a starting point with less complex UI management

For server configuration, just copy the jar file (LoginExtension.jar) on LoginExtension/bin folder on a new folder in SFS/extensions/ directory and enable the extension on Zone Configuration. You can just leave the extension aside and use the login provide by the Zone

The contents of the .7z file are:
- batallaNavalDB.sql => SQL instructions for create DB tables needed for running the example as it it (this isn't needed if you don't want custom login)
- LoginExtension => Folder with eclipse project for the extension for custom login. Include the needed .jar file in /bin directory (this isn't needed if you don't want custom login)
- SFS_chat => Folder with android project for the app itself. Contains all the client code to stablish connection with K.I.S.S principle

The code is GPL licensed so you are free for copy, distribute and adapt it to your needs, only authoring mentioning is wanted


Greetings from Colombia

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 2 guests