private void OnDeploymentListReceived(DeploymentList deployments, Action <Worker.Deployment> handleDeploymentChosen) { if (!string.IsNullOrEmpty(deployments.Error)) { throw new Exception(string.Format("Could not retrieve deployment list for project '{0}': {1}", SpatialOS.Configuration.ProjectName, deployments.Error)); } if (deployments.Deployments.Count == 0) { throw new Exception(string.Format("Could not find any deployments in project '{0}'", SpatialOS.Configuration.ProjectName)); } Deployment chosenDeployment; if (string.IsNullOrEmpty(SpatialOS.Configuration.DeploymentId)) { // No deployment was specified, so pick the first one returned by the Locator. chosenDeployment = deployments.Deployments.First(); if (deployments.Deployments.Count > 1) { Debug.LogError(string.Format("Locator returned {0} deployments, picking first the first one ('{1}')", deployments.Deployments.Count, chosenDeployment.DeploymentName)); } } else { // A deployment was specified, so we either find it or fail. chosenDeployment = deployments.Deployments.Find(d => d.DeploymentName == SpatialOS.Configuration.DeploymentId); if (chosenDeployment.Equals(default(Deployment))) { throw new Exception(string.Format("Could not find deployment '{0}' in project '{1}'", SpatialOS.Configuration.DeploymentId, SpatialOS.Configuration.ProjectName)); } } handleDeploymentChosen(chosenDeployment); }
public void TestGetDeploymentsList() { DeploymentList list = c.GetDeploymentList(); Assert.IsTrue(list.deployments.Count > 0); list = c.GetDeploymentList(KNOWN_DEPLOYMENT); Assert.IsTrue(list.deployments.Count == 1); }
public object Clone() { var tConfiguration = new DeploymentConfiguration { Shards = Shards != null?Shards.Clone() : null, DeploymentList = DeploymentList != null?DeploymentList.Clone() : null, DeploymentName = DeploymentName != null?DeploymentName.Clone() : null }; return(tConfiguration); }
internal static void LogObject(DeploymentList deploymentList) { if (deploymentList == null) return; Console.WriteLine("DeploymentList contains {0} item(s).", deploymentList.Count); foreach (var item in deploymentList) { LogObject(item); } }
/// <summary> /// Selects a deployment to connect to. /// </summary> /// <param name="deploymentList">The list of deployments to choose from.</param> /// <returns>The name of the deployment to connect to.</returns> /// <exception cref="ConnectionFailedException">The deployment list contains an error or is empty.</exception> protected virtual string SelectDeploymentName(DeploymentList deploymentList) { if (deploymentList.Error != null) { throw new ConnectionFailedException($"Failed to list deployments with error: ${deploymentList.Error}", ConnectionErrorReason.DeploymentNotFound); } if (deploymentList.Deployments.Count == 0) { throw new ConnectionFailedException("Could not find any deployments to connect to.", ConnectionErrorReason.DeploymentNotFound); } return(deploymentList.Deployments[0].DeploymentName); }
/// <summary> /// Selects which deployment to connect to. /// </summary> /// <param name="deployments">The list of deployments.</param> /// <returns>The name of the deployment to connect to.</returns> protected virtual string SelectDeploymentName(DeploymentList deployments) { return(null); }
protected override string SelectDeploymentName(DeploymentList deployments) { // This could be replaced with a splash screen asking to select a deployment or some other user-defined logic. return(deployments.Deployments[0].DeploymentName); }
protected override string SelectDeploymentName(DeploymentList deployments) { return(deployments.Deployments[0].DeploymentName); }
} internal static void LogObject(Certificate certificate) { if (certificate == null) return; if (certificate.CertificateUrl != null) { Console.WriteLine("Certificate Url:{0}", certificate.CertificateUrl.ToString()); }