More questions about userVariables!

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

Moderators: Lapo, Bax

fonager
Posts: 9
Joined: 15 Apr 2005, 10:52
Location: Denmark

More questions about userVariables!

Postby fonager » 16 Apr 2005, 07:38

I have a few questions about uservariables :

1) Why isnt there a "setVariable()" function, so I can set/change a single uservariable instead of collecting all uservariables in total and post them using "setUserVariables()" function ? It seems like "overkill" that I have to send all variables each time one of my variables has changed ...

2) When I change the uservariables using "setUserVariables()", what actually happens "on the TCP socket" ? Is a notification send to each user about the uservariables changes, or are ALL uservariables actually sent "down the wire" to each user ? I mean, if a heavy user has 100 uservariables, all being a long string, and one of these are changed, will each user in the room then recieve 100 * strings "downloaded" from the server into their client ?

Thanks for making a great product :D


-
Regards from Copenhagen,

Tony Fonager
User avatar
Lapo
Site Admin
Posts: 21095
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Apr 2005, 14:57

Again, sorry for the delay in responding. For some reason I did not receive notifications about the new topic.

Back to your questions:

1)
Setting server variables (UserVars, RoomVars) is already optimized. You don't have to send all the data every time and you receive only variables that where changed.

If you take a look to the Avatar Chat example you will notice that we're updating only the data we need (px, py and init) but we don't send the color of the avatar each time. The color is created once and never sent again.

Also by using the setUserVariables() method you can decide to update one single variable only or a group of variables in one shot, making it pretty flexible.


2)
As I said before only variables that where changed are broadcasted to the other users in the room.
It is obviously important to optimize the type of data you're using: if you end up having 100 long strings you should rethink your application because that would be very heavy in terms of bandwidth usage.

In other words the data sent through the TCP socket is only representing the updated variables.

Let me know if you have more questions.

:)
Lapo
--
gotoAndPlay()
...addicted to flash games
fonager
Posts: 9
Joined: 15 Apr 2005, 10:52
Location: Denmark

Postby fonager » 21 Apr 2005, 07:04

So If I have users with 10 variables each, and I make a new object and add only one of the variables and send that using setUserVariables(), that is the only variable being updated.

Thats nice!
Friendly greetings,

Tony Fonager
Copenhagen, Denmark
User avatar
Lapo
Site Admin
Posts: 21095
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Apr 2005, 08:19

Of course :)
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 22 guests