Question on room variables updates

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Bathory
Posts: 54
Joined: 17 Sep 2011, 21:47

Question on room variables updates

Postby Bathory » 10 Feb 2017, 16:39

Hello,

Quick question... When a user joins a room, he doesn't get all the room variables automatically on join? setRoomVariables needs to happen before that (either caused by an action from another user or from the server itself) and the user needs to listen to ROOM_VARIABLES_UPDATE, am I right?

Thank you
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Question on room variables updates

Postby Lapo » 10 Feb 2017, 18:04

Bathory wrote:Hello,

Quick question... When a user joins a room, he doesn't get all the room variables automatically on join?

Yes, he does.

setRoomVariables needs to happen before that (either caused by an action from another user or from the server itself) and the user needs to listen to ROOM_VARIABLES_UPDATE, am I right?

It's two different things.
When you join a Room you automatically get all of the variables that are set in it with the ROOM_JOIN event.
If you want you can already cycle through all available variables, if any.

The ROOM_VARIABLES_UPDATE, is a different event that will be fired after you have joined one (or more) Room(s) to tell you that variables have been updated.

To recap:
ROOM_JOIN gives you the Room object containing all current variables.
ROOM_VARIABLES_UPDATE will trigger if changes are made to one or more RoomVariables, after you've joined.

Makes sense?
Lapo
--
gotoAndPlay()
...addicted to flash games
Bathory
Posts: 54
Joined: 17 Sep 2011, 21:47

Re: Question on room variables updates

Postby Bathory » 10 Feb 2017, 19:47

Absolutely thank you so much Lapo.

So far I was handling almost all data transmitted with custom requests and responses. Before I start using room/user variables more... from what I understand in the docs, there is continuous communication/acknowledgement between the client and the server to make sure variables updates are well processed (unless UDP is used)?

Let's say the client didn't receive a packet with room variables updates because of a temporary disconnect, when he returns, does he have to circle through the variables in CONNECTION_RESUME (I'm guessing no because I haven't seen any example that does that)... or in that case will ROOM_VARIABLES_UPDATE be fired multiple times? Or just once with the latest data?

Thanks again.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Question on room variables updates

Postby Lapo » 11 Feb 2017, 10:44

Bathory wrote:Absolutely thank you so much Lapo.

So far I was handling almost all data transmitted with custom requests and responses. Before I start using room/user variables more... from what I understand in the docs, there is continuous communication/acknowledgement between the client and the server to make sure variables updates are well processed (unless UDP is used)?

Yes this is correct.
I'd recommend checking our basic examples with source code to learn this a bit more in depth:
http://smartfoxserver.com/download/sfs2x#p=examples

Let's say the client didn't receive a packet with room variables updates because of a temporary disconnect, when he returns, does he have to circle through the variables in CONNECTION_RESUME (I'm guessing no because I haven't seen any example that does that)... or in that case will ROOM_VARIABLES_UPDATE be fired multiple times? Or just once with the latest data?

Yes the ROOM_VARIABLES_UPDATE will fire multiple times. In other words you will receive all events that the server wasn't able to send you during the temporary disconnection.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 42 guests