From c62cf6ba6fad43d1159c24440a06c4fc856c365c Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 12 Nov 2008 00:30:35 +0000 Subject: [PATCH] Don't start our tick interval until we've successfully logged on. There's no utility in sending pings before we're authenticated. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5543 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/presents/client/Client.as | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/as/com/threerings/presents/client/Client.as b/src/as/com/threerings/presents/client/Client.as index caac57e9a..7d7f871af 100644 --- a/src/as/com/threerings/presents/client/Client.as +++ b/src/as/com/threerings/presents/client/Client.as @@ -267,13 +267,6 @@ public class Client extends EventDispatcher _comm = new Communicator(this); callLater(_comm.logon); - // it is safe, however, to start up our tick interval immediately - if (_tickInterval == null) { - _tickInterval = new Timer(5000); - _tickInterval.addEventListener(TimerEvent.TIMER, tick); - _tickInterval.start(); - } - return true; } @@ -320,10 +313,12 @@ public class Client extends EventDispatcher if (abortable && !notifyObservers(ClientEvent.CLIENT_WILL_LOGOFF)) { return false; } - - _tickInterval.stop(); - _tickInterval = null; - + + if (_tickInterval != null) { + _tickInterval.stop(); + _tickInterval = null; + } + _comm.logoff(); return true; } @@ -372,7 +367,16 @@ public class Client extends EventDispatcher */ public function gotClientObject (clobj :ClientObject) :void { + // keep our client object around _clobj = clobj; + + // and start up our tick interval (which will send pings when necessary) + if (_tickInterval == null) { + _tickInterval = new Timer(5000); + _tickInterval.addEventListener(TimerEvent.TIMER, tick); + _tickInterval.start(); + } + notifyObservers(ClientEvent.CLIENT_DID_LOGON); }