UserVariables callback batched?

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

Moderators: Lapo, Bax

Nexic
Posts: 31
Joined: 26 Jun 2008, 12:23

UserVariables callback batched?

Postby Nexic » 25 Aug 2017, 08:33

I've tried to find an answer to this question in the docs, but haven't had any luck. Apologies if it's been covered before.

Essentially, can the "changedVars" paramter from the OnUserVariableUpdate call back ever receive batched results from multiple update requests?

For example, I send two user variable updates (in pseudo code):

Code: Select all

SendVariables(A="hello", B="you said hello");
SendVariables(C = "goodbye", B="you said goodbye");


Will the receiving client *always* get two OnUserVariableUpdate? IE:

Code: Select all

changedVars = A="hello", B="you said hello"

Then

changedVars = C = "goodbye", B="you said goodbye"


Or is it possible in certain circumstances you might only receive one callback? IE

Code: Select all

changedVars = A="hello", B="you said goodbye", C="goodbye"


Or still receive two callbacks, but with some 'merged' results?

Code: Select all

changedVars = A="hello", B="you said goodbye"

Then

changedVars = C="goodbye",  B="you said goodbye"



The reason I'm asking is I've seen some rare behaviour which seems to be similar to this. I can't figure out if it's a mistake in my design or if that's just how SFS is supposed to operate under certain conditions. Essentially I'm trying to hash each set of user var updates sent, so that the clients can check the validity of the new data before acting on it. However if you ever get "merged" results this technique doesn't work.

If batching/merging does happen, is there any way to disable or otherwise prevent this behaviour?

Thanks in advance :)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UserVariables callback batched?

Postby Lapo » 25 Aug 2017, 11:16

Hi,
batching / merging does not happen. Every update will generate its corresponding client side event.

Example if you send these updates in rapid succession
A = 10, B = 20
A = 0, B = 1, C = 2

you will get two separate SFSEvent.USER_VARIABLE_UPDATE on the client with the respective list of changes.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Nexic
Posts: 31
Joined: 26 Jun 2008, 12:23

Re: UserVariables callback batched?

Postby Nexic » 25 Aug 2017, 11:17

Brilliant, thanks for clarifying!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 60 guests