From 7faeb29c4f3fcb8c65e62b989c8634a190862c46 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Fri, 22 Apr 2011 15:58:45 +0000 Subject: [PATCH] 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 --- .../as/com/threerings/presents/client/Client.as | 13 ++++++++++++- .../com/threerings/presents/client/Communicator.as | 5 ++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/as/com/threerings/presents/client/Client.as b/src/main/as/com/threerings/presents/client/Client.as index 28ffb6c22..5e870214b 100644 --- a/src/main/as/com/threerings/presents/client/Client.as +++ b/src/main/as/com/threerings/presents/client/Client.as @@ -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 diff --git a/src/main/as/com/threerings/presents/client/Communicator.as b/src/main/as/com/threerings/presents/client/Communicator.as index aa22c5068..e0636339b 100644 --- a/src/main/as/com/threerings/presents/client/Communicator.as +++ b/src/main/as/com/threerings/presents/client/Communicator.as @@ -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); }