Problem when send request from android client at high speed

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

Moderators: Lapo, Bax

hhd90
Posts: 67
Joined: 21 Dec 2012, 05:17

Problem when send request from android client at high speed

Postby hhd90 » 05 Dec 2013, 10:05

Hi smartfoxTeam,
I have problem when send and receive data from Android client. I tried a simple scenario : send a simple request contain a variable packetId which increase by one after request sent. I print out the id when call send method and the id when receive packet. A strange thing happen the id order is not the same. If the id send from android client is : 0,1,2,3,4,5,6 the id order receive is 0,1,3,2,5,4,6. The client sends request after each 50 ms. I am developing a real time game, if the order of request is changed, my game result may be affected. How do I handle this problem ?

Thanks !
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem when send request from android client at high sp

Postby Lapo » 05 Dec 2013, 16:53

You mean that you are sending the packets in order and you don't see the same order on the server side?

In general it is normal. High speed rates will likely do that, the reason is mainly due to the server side multithreading. Packets will arrive at the server in order but since there are multiple threads working on your requests you are not guaranteed ordering on the way back.

There are several ways to address this. Take in consideration that when you send lots of fast position changes the out of order scenario is very common and you normally have to deal with it. In other words if you are processing packet #20 and then you receive packet #19 you can already discard it because you have already updated the server state to a more recent packet.
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 31 guests