Adding extra connection guards to HostCoordinator

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@220 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Robert Zubeck
2007-03-01 20:08:28 +00:00
parent 14284325e2
commit a27c60e4fe
@@ -158,6 +158,10 @@ public class HostCoordinator extends EventDispatcher
*/ */
protected function getHostId (claimIfAvailable : Boolean = false) : Number protected function getHostId (claimIfAvailable : Boolean = false) : Number
{ {
if (! _control.isConnected()) {
return 0;
}
var host : Object = _control.get(HOST_NAME); var host : Object = _control.get(HOST_NAME);
if (host == null || // no host was recorded, or if (host == null || // no host was recorded, or
@@ -167,7 +171,6 @@ public class HostCoordinator extends EventDispatcher
tryReplaceHost (host); tryReplaceHost (host);
} }
return 0; return 0;
} else { } else {
// otherwise, the host is present and known // otherwise, the host is present and known
return Number(host); return Number(host);
@@ -181,10 +184,12 @@ public class HostCoordinator extends EventDispatcher
*/ */
protected function tryReplaceHost (hostId : Object) : void protected function tryReplaceHost (hostId : Object) : void
{ {
if (_control.isConnected()) {
debugLog("Removing old host with id " + hostId); debugLog("Removing old host with id " + hostId);
_control.testAndSet (HOST_NAME, _control.getMyId (), hostId); _control.testAndSet (HOST_NAME, _control.getMyId (), hostId);
debugHostStatus (); debugHostStatus ();
} }
}
/** Debug only */ /** Debug only */
protected function debugLog (message : String) : void protected function debugLog (message : String) : void