Can't Login to Zone with Java

Post here all your questions related with SmartFoxServer Java API

Moderators: Lapo, Bax

crtjer
Posts: 5
Joined: 30 Dec 2008, 16:13

Can't Login to Zone with Java

Postby crtjer » 30 Dec 2008, 16:16

I have attempted to create a Java client that connects to SFS server. I used the tutorial to connect to the server and that works fine however connecting to a zone doesn't seem to work. In my onConnection handler, I call the login method to the zone. After this it seems to hang. Any ideas? Thanks a lot.
crtjer
Posts: 5
Joined: 30 Dec 2008, 16:13

Postby crtjer » 30 Dec 2008, 19:37

Continuing on and debugging more. I found out that I send out complete xml string but I receive a broken xml string back from the server. Any ideas? Thank you very much.[/quote]
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 31 Dec 2008, 10:37

What version of the server is being used?
Can you show the code that doesn't work?
Finally the XML coming back should not be broken. Where do you see that is malformed? Can you show what you get back exactly?

Happy new year :)

p.s. = I have moved this in the BETA API section, it's more appropriate
Lapo
--
gotoAndPlay()
...addicted to flash games
crtjer
Posts: 5
Joined: 30 Dec 2008, 16:13

Postby crtjer » 09 Jan 2009, 22:08

Code: Select all

01-05 14:13:02.534: VERBOSE/SMARTFOXAPP(197): onConnection listener set up.
01-05 14:13:02.534: VERBOSE/SMARTFOXAPP(197): onJoinRoom listener set up.
01-05 14:13:02.534: VERBOSE/SMARTFOXAPP(197): onRoomListUpdate listener set up.
01-05 14:13:02.713: VERBOSE/SMARTFOXAPP(197): [Sending]:<msg t ='sys'><body action='verChk' r='0'><ver v='154' /></body></msg>
01-05 14:13:02.752: VERBOSE/SMARTFOX(197): [RECEIVED]: <cross-domain-policy><allow-access-from domain='*' to-ports='9339' /></cross-domain-policy>, (len: 91)
01-05 14:13:02.893: INFO/ActivityManager(49): Displayed activity com.ibm.SmartFoxApp/.SmartFoxApp: 1179 ms
01-05 14:13:02.944: INFO/global(197): Jan 5, 2009 2:13:02 PM java.io.BufferedReader <init>
01-05 14:13:02.944: INFO/global(197): INFO: Default buffer size used in BufferedReader constructor. It would be better to be explicit if a 8k-char buffer is required.
01-05 14:13:03.002: VERBOSE/SMARTFOX(197): [RECEIVED]: , (len: 0)


I'm trying to connect to a SmartFoxPro Server.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 10 Jan 2009, 15:19

hmmm...
what kind of application is this? Are you using our beta Java API?
Those logs don't look very familiar to me. Additionally from what I can see the XML you are receiving is correct.

Please give us more details on the problem.
Lapo

--

gotoAndPlay()

...addicted to flash games
crtjer
Posts: 5
Joined: 30 Dec 2008, 16:13

Postby crtjer » 11 Jan 2009, 01:27

I am using the Java Beta API and I'm using this under Android. The Debug you see is the SmartFoxServer debug statements just using the Android logger. I'm using the sample code from the Java Beta API rar that is provided. As I was debugging it seems like XMLSocket isn't connecting properly. This is just through debugging it step by step. Thanks for you help.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Jan 2009, 07:18

I am sorry, unfortunately the Java API are not currently tested under Android.
As far as I know Google's platform supports a large selection of the Java2SE framework but I am not sure of the limitations.
The XMLSocket library used in the API contain the core socket classes which use java.nio behind the scenes. I guess there could be compatibility problems between at that level.

We'll take a look when we have time and see if we can provide a wrapper or an alternative socket library that works correctly under Android.

Thanks for reporting
Lapo

--

gotoAndPlay()

...addicted to flash games
crtjer
Posts: 5
Joined: 30 Dec 2008, 16:13

Postby crtjer » 12 Jan 2009, 18:39

Is there anyway I can be given the source for the XMLSocket.jar so I can investigate and possibly create a fix for it? Thank you very much for your responses.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 13 Jan 2009, 07:07

The problem is unlikely to be there, as the XMLSocket library is based on xsocket which is the socket library being used.
http://xsocket.sourceforge.net/

I've given another look that log you have posted I am still clueless about what the problem is, exactly.
You seem to be able to establish a connection and receive a couple of messages from the server correctly.
This means that most of the core stuff is actually working pretty well, otherwise you wouldn't be able to even start a connection.

Can you say where the BufferedReader warning is coming from? Is it your code instantiating that object?
As far as I can remember the SFS API code shouldn't use any of those unless it's coming from the socket library.
Also, after you receive an empty message you don't seem to be sending any other requests... what is exactly going on after that?
Is there more to that log data?
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 19 Jan 2009, 17:23

I have an update on this.
We have an alternative version of XMLSocket library which uses Apache Mina instead of the XSocket library.

XSocket seems to refer to Java RMI which is not supported by Android.
If you want to try the Mina-based API drop us an email and we'll send the jars. It won't require any changes in your code, just replacing the references to the external libraries in your IDE

Hope it helps :)
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Jan 2009, 07:55

One more update:
I can confirm that the Mina-based XMLSocket library works flawlessly under Android. Tested with the latest Android SDK available as of Jan 20th 2009

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
promore
Posts: 2
Joined: 26 Oct 2009, 14:10

Postby promore » 26 Oct 2009, 14:22

if you want to toggle the ONLOGIN event you must set the server/config.xml the zone tags's attribute customLogin = true
then you can handle event in your client !
I hope it can help you!
Friend from China! :lol:

Return to “Java2SE / Android Client API”

Who is online

Users browsing this forum: No registered users and 4 guests