Macromedia flash media server 2-client-side actionscript language reference for flash media server 2 Benutzerhandbuch

Seite von 156
114
Client-Side ActionScript Language Reference
Data design and management
Data associated with shared objects are stored in attributes of the object’s 
data
 properties; 
each set of attributes constitutes one slot. For example, the following lines assign values to 
three slots of a shared object:
my_so.data.userID = "myLogonName";
my_so.data.currentStatus = "in a meeting";
my_so.data.lastLogon = "February 27, 2002";
Each time a client changes an attribute, all the attributes for that slot are sent to the server and 
then propagated to all clients attached to the object. Thus, the more information a slot 
contains, the more network traffic is generated when any attribute in that slot is changed.
For example, consider a shared object with the following attributes occupying a single slot:
my_so.data.year.month.dayOfMonth = someValue; 
If a client changes the value of the 
year
month
, or 
dayOfMonth
 attribute, the entire slot is 
updated, even though only one data item was changed. 
Compare this data structure to a shared object with the same attributes, but with a flat design 
that occupies three slots instead of one:
my_so.data.year = someValue;
my_so.data.month = someValue;
my_so.data.dayOfMonth = someValue;
In this case, because each slot contains only one piece of information, less bandwidth is 
required to update all connected clients when a single data attribute is changed. 
You can use this information when designing your remote shared objects. For example, if an 
object is designed to be updated frequently by multiple clients in real time, minimizing the 
amount of data per slot can improve performance. This design can also help minimize data 
collisions (multiple clients trying to change a single slot at the same time).
Conflict resolution
If more than one client (or server application) can change the data in a single slot of your 
shared object at the same time, you must implement a conflict-resolution strategy. Here are 
some examples:
Use different slots
  The simplest strategy is to use a different slot for each player or server 
that might change data in the object. For example, in a shared object that keeps track of users 
in a chat room, provide one slot per user and have users modify only their own slots.