/// <summary> /// Creates the Locator configuration. /// </summary> /// <remarks> /// If in a standalone build, will use the command line arguments. /// </remarks> /// <param name="workerType">The type of the worker to create.</param> /// <returns>The Locator connection configuration</returns> protected virtual LocatorConfig GetLocatorConfig(string workerType) { var commandLineArguments = Environment.GetCommandLineArgs(); var commandLineArgs = CommandLineUtility.ParseCommandLineArgs(commandLineArguments); var config = LocatorConfig.CreateConnectionConfigFromCommandLine(commandLineArgs); config.WorkerType = workerType; config.WorkerId = CreateNewWorkerId(workerType); return(config); }
public static ConnectionConfig CreateConnectionConfigFromCommandLine(Dictionary <string, string> parsedArgs) { if (parsedArgs.ContainsKey(RuntimeConfigNames.LoginToken)) { return(LocatorConfig.CreateConnectionConfigFromCommandLine(parsedArgs)); } else { return(ReceptionistConfig.CreateConnectionConfigFromCommandLine(parsedArgs)); } }
public static LocatorConfig CreateConnectionConfigFromCommandLine(Dictionary <string, string> parsedArgs) { var config = new LocatorConfig(); var loginToken = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LoginToken, string.Empty); var projectName = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.ProjectName, string.Empty); config.SetLoginToken(loginToken); config.SetProjectName(projectName); config.LocatorHost = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LocatorHost, RuntimeConfigDefaults.LocatorHost); config.LinkProtocol = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LinkProtocol, RuntimeConfigDefaults.LinkProtocol); return(config); }
public static Connection LocatorConnectToSpatial(LocatorConfig config, string workerType) { config.Validate(); using (var locator = new Locator(config.LocatorHost, config.LocatorParameters)) { Debug.Log("Attempting to retrieve deployment name..."); var deploymentName = GetDeploymentName(locator); Debug.Log("Successfully obtained deployment name!"); Debug.Log("Attempting connection to SpatialOS with Locator..."); var parameters = CreateConnectionParameters(config, workerType); using (var connectionFuture = locator .ConnectAsync(deploymentName, parameters, status => true)) { return(TryToConnect(connectionFuture)); } } }
/// <summary> /// Creates a <see cref="LocatorConfig"/> instance from a set of command line arguments. /// </summary> /// <param name="parsedArgs">A dictionary of command line argument to command line value.</param> /// <returns>A <see cref="LocatorConfig"/> instance.</returns> public static LocatorConfig CreateConnectionConfigFromCommandLine(Dictionary <string, string> parsedArgs) { var config = new LocatorConfig(); var projectName = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.ProjectName, string.Empty); config.SetProjectName(projectName); var loginToken = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LoginToken, string.Empty); if (!string.IsNullOrEmpty(loginToken)) { config.SetLoginToken(loginToken); } var steamDeploymentTag = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.SteamDeploymentTag, string.Empty); var steamTicket = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.SteamTicket, string.Empty); if (!string.IsNullOrEmpty(steamDeploymentTag) && !string.IsNullOrEmpty(steamTicket)) { config.SetSteamCredentials(steamDeploymentTag, steamTicket); } config.LocatorHost = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LocatorHost, RuntimeConfigDefaults.LocatorHost); config.LinkProtocol = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LinkProtocol, RuntimeConfigDefaults.LinkProtocol); config.WorkerId = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.WorkerId, string.Empty); config.WorkerType = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.WorkerType, string.Empty); return(config); }