Room Variable Update issue . . .

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

Moderators: Lapo, Bax

Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Room Variable Update issue . . .

Postby Fishypants » 08 Nov 2011, 20:46

Hey everyone. I have everything working correctly, my question is more of a design question of the server.

This is what the docs say about when room variables update:
The event is fired when room variables are updated in a certain room. A client receives these notifications only from the room(s) where he's currently logged in.
To optimize bandwidth only the variables that changed are transmitted.


But this seems to be a waste and doesn't really optimize the bandwidth at all . . . In what situation would you really need to know that a variable changed, yet not want the value that the variable was set to? The current method seems like a lot of unnecessary work. So the logic is as follows:


1) Something happens on server and variables change. Server sends notification to all the clients in the room of this change.
2) All the clients need the value of the changed variable so they all ask the server for the value.
3) Server returns the value to all the clients.

This doesn't seem optimized at all. It's almost double the amount of work. Why can't the server send the variables that changed as well as their value? Like this:

1) Something happens on server and variables change. Server sends variables and values to clients.
2) Clients get new values.

Or am i missing something entirely? Just something that's been bothering me recently. It seems like there would be a speed increase (or maybe I'm completely wrong) with sending an initial heavier packet as opposed to a roundabout trip from server to client.
Last edited by Fishypants on 08 Nov 2011, 20:52, edited 1 time in total.
Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Postby Fishypants » 08 Nov 2011, 20:50

Hmmm upon further thinking, I suppose if there was data that you only wanted a select group of people to receive, then the current implementation would be ideal, since theres less data going to people who don't need it.

But unfortunately, this is not my case. Every variable in the room is a variable that everyone should know about and update to. In my case this seems more inefficient. Is there a way to force the server to send the values as well? Some awesome undocumented method thats not in the docs?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 08 Nov 2011, 22:15

Hi. It seems there is some confusion about how the server handles the room variables. When you update some variables of a room, the server only sends to the users that are inside the name of the variable that was updated plus its value.

Despite the onRoomListUpdate method only having the room and the changedVars array, when that event is fired the client has also received the new values of those vars. So in that event you just do the room.getVariable("varName"). Note: this method doesnt send a request to the server asking for the new value, it only returns the value that is already stored on the client.

So as you can see, this is already improved a lot :-)
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Postby Fishypants » 09 Nov 2011, 02:44

Wait, really? How have I missed that? I thought room.getVariable() requested the variables from the server . . . IF not then that's excellent news! :D I need to read up more on that. Do you happen to know where in the documentation it mentions the variables being stored in the client?
Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Postby Fishypants » 09 Nov 2011, 02:52

The Room class is used internally by the SmartFoxClient object to store the properties of each room.


:shock: Well so it does. Bah, I don't know how I overlooked that. Thanks for the insight rjgtav. I wish the documentation was a little more clearer on this subject, or maybe there is information somewhere else that I am blatantly overlooking. Anyways, thanks again! :D

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 23 guests