
About Flash Communication Server Applications 29
Finally, here’s an overview of the remote shared object flow. A Flash client movie subscribes to a
remote shared object by issuing a
SharedObject.getRemote command, and provides a
SharedObject.onSync method with it. The client then connects the remote shared object to the
NetConnection object by issuing a
SharedObject.connect command. The server sends out a
synchronization message for the shared object, but no method on the server side is invoked. This
synchronization message causes the
SharedObject.onSync method on the client to be called.
When the client, the server, or any other movie instance makes a change to the shared object, the
server again sends out a synchronization message for the shared object. Again, no server method is
called, and the synchronization message from the server causes the
SharedObject.onSync
method on each client to be called.
Shared object flow
Designing Flash Communication Server applications
Now that you have a basic understanding of the structure and capabilities of Flash
Communication Server, you need to consider how to design your own applications to best take
advantage of client-side and server-side scripting.
When designing a Flash Communication Server application, determine what capabilities it will
have, what it requires of the server, and whether the application’s capabilities call only for client-
side ActionScript or for server-side ActionScript as well. If you want the server to act as a conduit
for your audio, video, and text streams, you might need only client-side ActionScript; if you want
the server to process data, you’ll need to write server-side ActionScript as well.
Although building client-server applications may seem complicated, in many cases it is easier to
write a small amount of server-side code than it is to handle everything in client-side code. (Of
course, in some cases, only server-side code can accomplish certain tasks.) For example, server-
side scripts can act as a “gatekeeper” for your application; by setting certain data on the server, you
can eliminate race conditions (multiple clients attempting to perform the same task at the same
time) and may eliminate the need for client-side code to handle conflict resolution.
SERVER FLOW
Sync
(Initialize data)
Sync
(Update data)
CLIENT 1 FLOW
onSync
"clear"
obj1.data.x=4
onSync
"success"
getRemote("obj1")
connect
CLIENT 2 FLOW
onSync
"clear"
onSync
"change"
getRemote("obj1")
connect
Commentaires sur ces manuels