Allow downstream and upstream messages to be compounded

A client can collect a bunch of messages into a CompoundUpstreamMessage, which are unpacked and
dispatched in order by the server. The server collects any messages sent while processing that
compound message into a CompoundDownstreamMessage, which is unpacked and dispatched by the client.

This allows the client to indicate that it's going to send enough messages that it'd blow out the
throttle, but that it's doing so intentionally.



git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6659 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2011-06-16 03:37:08 +00:00
parent 604e11e93e
commit 52023608c8
10 changed files with 333 additions and 43 deletions
@@ -20,7 +20,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.client {
import flash.events.EventDispatcher;
import flash.events.TimerEvent;
@@ -280,6 +279,21 @@ public class Client extends EventDispatcher
return true;
}
/**
* Runs the given function while collecting any generated messages in a CompoundEvent, which
* will be sent when the function returns.
*/
public function inCompoundMessage (run :Function) :void
{
_comm.startCompoundMessage();
try {
run();
} finally {
_comm.finishCompoundMessage();
}
}
/**
* Create the client property object to pass to {@link ObjectInputStream}. Subclasses may
* add references useful during e.g. deserialization.