Open ourselves up a bit, to let subclasses pass their own data through ObjectInputStream's handy clientProps functionality. A prime example: sending along an injection context to streamed objects.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6630 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -273,11 +273,22 @@ public class Client extends EventDispatcher
|
||||
// we need to wait for the CLIENT_WILL_LOGON to have been dispatched before we actually
|
||||
// tell the communicator to logon, so we run this through the callLater pipeline
|
||||
_comm = new Communicator(this);
|
||||
callLater(_comm.logon);
|
||||
callLater(function () :void {
|
||||
_comm.logon(buildClientProps());
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the client property object to pass to {@link ObjectInputStream}. Subclasses may
|
||||
* add references useful during e.g. deserialization.
|
||||
*/
|
||||
protected function buildClientProps () :Object
|
||||
{
|
||||
return { invDir: _invdir };
|
||||
}
|
||||
|
||||
/**
|
||||
* Transitions a logged on client from its current server to the specified new server.
|
||||
* Currently this simply logs the client off of its current server (if it is logged on) and
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.threerings.presents.client {
|
||||
|
||||
import flash.errors.IOError;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
@@ -55,13 +54,13 @@ public class Communicator
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public function logon () :void
|
||||
public function logon (clientProps :Object = null) :void
|
||||
{
|
||||
// create our input/output business
|
||||
_outBuffer = new ByteArray();
|
||||
_outBuffer.endian = Endian.BIG_ENDIAN;
|
||||
_outStream = new ObjectOutputStream(_outBuffer);
|
||||
_inStream = new ObjectInputStream(null, { invDir: _client.getInvocationDirector() });
|
||||
_inStream = new ObjectInputStream(null, clientProps);
|
||||
|
||||
attemptLogon(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user