From a27c60e4fe82775fa19f0fc7c343ac82dcb3973c Mon Sep 17 00:00:00 2001 From: Robert Zubeck Date: Thu, 1 Mar 2007 20:08:28 +0000 Subject: [PATCH] Adding extra connection guards to HostCoordinator git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@220 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/as/com/threerings/ezgame/HostCoordinator.as | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/as/com/threerings/ezgame/HostCoordinator.as b/src/as/com/threerings/ezgame/HostCoordinator.as index 65414d6b..8cf017b7 100644 --- a/src/as/com/threerings/ezgame/HostCoordinator.as +++ b/src/as/com/threerings/ezgame/HostCoordinator.as @@ -158,6 +158,10 @@ public class HostCoordinator extends EventDispatcher */ protected function getHostId (claimIfAvailable : Boolean = false) : Number { + if (! _control.isConnected()) { + return 0; + } + var host : Object = _control.get(HOST_NAME); if (host == null || // no host was recorded, or @@ -167,7 +171,6 @@ public class HostCoordinator extends EventDispatcher tryReplaceHost (host); } return 0; - } else { // otherwise, the host is present and known return Number(host); @@ -181,9 +184,11 @@ public class HostCoordinator extends EventDispatcher */ protected function tryReplaceHost (hostId : Object) : void { - debugLog("Removing old host with id " + hostId); - _control.testAndSet (HOST_NAME, _control.getMyId (), hostId); - debugHostStatus (); + if (_control.isConnected()) { + debugLog("Removing old host with id " + hostId); + _control.testAndSet (HOST_NAME, _control.getMyId (), hostId); + debugHostStatus (); + } } /** Debug only */