From 3ad606c3271bc1cdaa0a46b738735e1a9404fa50 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 8 Dec 2017 11:34:52 -0500 Subject: [PATCH] Fix some safety connectivity issues regarding IInstance enumeration --- TGS.Interface/Wrappers/IServer.cs | 2 +- TGS.Interface/Wrappers/Instance.cs | 3 +++ TGS.Interface/Wrappers/Server.cs | 17 ++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/TGS.Interface/Wrappers/IServer.cs b/TGS.Interface/Wrappers/IServer.cs index 130d622ca4..e06e7cb624 100644 --- a/TGS.Interface/Wrappers/IServer.cs +++ b/TGS.Interface/Wrappers/IServer.cs @@ -15,7 +15,7 @@ namespace TGS.Interface.Wrappers new Version Version { get; } /// - /// Get the s the contains that the current user can access + /// Get the s the contains that the current user can access and connect to /// IEnumerable Instances { get; } diff --git a/TGS.Interface/Wrappers/Instance.cs b/TGS.Interface/Wrappers/Instance.cs index 77e304af38..72d9e364b4 100644 --- a/TGS.Interface/Wrappers/Instance.cs +++ b/TGS.Interface/Wrappers/Instance.cs @@ -24,6 +24,9 @@ namespace TGS.Interface.Wrappers { serverInterface = _serverInterface; metadata = _metadata; + if (metadata.Enabled) + //run a connectivity check + serverInterface.GetComponent(metadata.Name).VerifyConnection(); } /// diff --git a/TGS.Interface/Wrappers/Server.cs b/TGS.Interface/Wrappers/Server.cs index 9276c64e88..71b918ffe2 100644 --- a/TGS.Interface/Wrappers/Server.cs +++ b/TGS.Interface/Wrappers/Server.cs @@ -14,10 +14,21 @@ namespace TGS.Interface.Wrappers public IEnumerable Instances { get { lock (this) - if(knownInstances == null) + if (knownInstances == null) knownInstances = serverInterface.GetComponent(null).ListInstances(); - foreach(var I in knownInstances) - yield return new Instance(serverInterface, I); + foreach (var I in knownInstances) + { + IInstance nextInstance; + try + { + nextInstance = new Instance(serverInterface, I); + } + catch + { + continue; + } + yield return nextInstance; + } } }