[Help!] Reduce Lag

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

x.Mara.x
Posts: 23
Joined: 18 Dec 2008, 20:03

[Help!] Reduce Lag

Postby x.Mara.x » 01 Mar 2009, 13:49

I need to reduce the lag for my project, it is not the server, it is the .fla file; each time that the user moves 1 tile 20 variables are sent and updated, making you see the others walk really really slow.. how can i reduce the lag?
User avatar
Lapo
Site Admin
Posts: 21723
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 01 Mar 2009, 17:34

You can by reducing the number of variables that you update (20 seems quite a lot, on every move) and the amount of updates per seconds.
Take into consideration that a good client conection can't handle more than 15-20 updates per second (50-70ms) and a not-so good one can handle <= 10 msg/second.
Lapo
--
gotoAndPlay()
...addicted to flash games
x.Mara.x
Posts: 23
Joined: 18 Dec 2008, 20:03

Postby x.Mara.x » 03 Mar 2009, 19:50

its that all variables seem to be essencial.. i mean i do not know how to reduce them.. because these are the variables that are essencial:

py
px
movefeat
look
init

but they are updating to often, if i dont update them though.. it doesnt work well.. the user sees other users moving really slooww

is there a way like.. umm.. putting all the values in 1 variable and then exploding them?
example:
instead of:
py
px
movefeet
look
init
(5), only one.. like this
all = py+","+px+","+movefeet+","+"look";
would that work?
aMUSiC
Posts: 48
Joined: 15 Dec 2007, 17:15

Postby aMUSiC » 04 Mar 2009, 09:21

Of course you can. You can either join your values into a single string using a delimiter (like a coma, but I prefer a pipe |, i.e. 14|56|4|19|1 ), or if you use standard lengths for your values, you can even put them as a a series of non delimited values (adding leading zeros to make them uniform i.e. 014056040191) and use substr or modulus to take the portion you need.

Use Array.join() and Array.split() for imploding/exploding (you're a php person eh?).

This will severely reduce the amount of traffic, HOWEVER you will add more calculations to the client which has to do the extra step of joining and splitting the values (which under normal circumstances is negligable).
x.Mara.x
Posts: 23
Joined: 18 Dec 2008, 20:03

Postby x.Mara.x » 05 Mar 2009, 19:49

how do you know im a php person o.o wow.. haha.. well ill try although i dont know how to do the exploding in the AS.. will it be something like this?:

when sending

var allin:Number = movefeet+","+ etc...

smartfox.setUserVariables(allin);

when receiving
myarray = Array.split(userObj, ",");
user._movefeet = myarray[0]

.. idk..

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 25 guests