Page 1 of 1

Client/Server Interaction Question

Posted: 16 Sep 2010, 19:16
by jimg
Can someone suggest the best approach for coordinating data between the client and server that relates to the user. If I'm understanding the documentation properly, it would seem that user variables are more appropriate for broadcasting information between users in a room - not synchronizing the state of a user between the client and server.

For example,

1. When the user logs in - what's the best way to return profile information from the server back to the client (such as Avatar details) - setUserVariables or include it in a sendResponse?

2. When the user changes the avatar on the client-side, what's the best mechanism to send the changes to the server AND do you wait for the server to confirm the changes before applying them on the client.

Any advice on general approach is greatly appreciated.

Thanks!

Posted: 16 Sep 2010, 19:56
by BigFIsh
This is what I do:

1. After a client logged in, I send everything to that client including avatars, gold etc using sendResponse method. On the server, I also store the avatar info as a user variable (but a shorter version). So when other users join the same room, they'll get the user variables straight away.

2. I just update the user variable when the avatar changes without boardcasting the event (in server side - as I would need to validate the data). All users in the current room won't know yet, until they re-join the room. I don't find it important to update the user's avatar in real time.

Posted: 16 Sep 2010, 20:07
by jimg
Thanks for the timely response!

That gives me some great information to work with.