UserVariable or ObjectMessage

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
alex_h
Posts: 15
Joined: 27 Feb 2009, 12:56
Location: Bath, UK

UserVariable or ObjectMessage

Post by alex_h »

I have a game with 4 players. I want each of them to broadcast the following properties to the other players:

x position
y position
x motion vector
y motion vector


I intend for each player to broadcast updates on events (eg motion start / change direction) and also on a set interval (maybe 500ms).
Each broadcast should be time stamped, and I want to use the ping / lag tracker value compared against the time stamps to correct for network delays.

Currently I have built a working model of most of this by creating a UserVariable for each property (including a 'time' property).
But I've just noticed that there is an 'ObjectMessage' that might do the job just as well or even better than UserVariables.
Is there a preferred convention as to when to use UserVariables and when to use ObjectMessage?
What are the pros and cons of each approach? Does one carry more overhead in terms of bandwidth?

thanks

Alex
IDVsbruck
Posts: 33
Joined: 25 Oct 2011, 09:43

Post by IDVsbruck »

It can have the reason ... I also came up with this idea.

It depends on at what point in the userVariables setting sends a message to client - immediately after setting (setUserVariables(.., .., true, ..)) or after work of server extension (handler or all extension). If it's immediately then it does not make sense. If after work of handler/extension then in theory you can win a little time.
Post Reply