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
{
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 */