/// <summary> /// Creates a Receptionist configuration. /// </summary> /// <remarks> /// If in a standalone build, will use the command line arguments. /// </remarks> /// <remarks> /// A worker ID is auto-generated if in the Unity Editor or if one is not provided over the command line. /// </remarks> /// <param name="workerType">The type of the worker to create.</param> /// <returns>The Receptionist connection configuration</returns> protected virtual ReceptionistConfig GetReceptionistConfig(string workerType) { ReceptionistConfig config; if (Application.isEditor) { config = new ReceptionistConfig { WorkerType = workerType, WorkerId = CreateNewWorkerId(workerType), UseExternalIp = UseExternalIp }; } else { var commandLineArguments = Environment.GetCommandLineArgs(); var commandLineArgs = CommandLineUtility.ParseCommandLineArgs(commandLineArguments); config = ReceptionistConfig.CreateConnectionConfigFromCommandLine(commandLineArgs); config.WorkerType = workerType; config.UseExternalIp = UseExternalIp; if (!commandLineArgs.ContainsKey(RuntimeConfigNames.WorkerId)) { 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 ReceptionistConfig CreateConnectionConfigFromCommandLine(Dictionary <string, string> parsedArgs) { var config = new ReceptionistConfig(); config.ReceptionistHost = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.ReceptionistHost, RuntimeConfigDefaults.ReceptionistHost); config.ReceptionistPort = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.ReceptionistPort, RuntimeConfigDefaults.ReceptionistPort); config.LinkProtocol = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LinkProtocol, RuntimeConfigDefaults.LinkProtocol); return(config); }
public static Connection ConnectToSpatial(ReceptionistConfig config, string workerType, string workerId) { config.Validate(); Debug.Log("Attempting connection to SpatialOS..."); var parameters = CreateConnectionParameters(config, workerType); using (var connectionFuture = Connection .ConnectAsync(config.ReceptionistHost, config.ReceptionistPort, workerId, parameters)) { return(TryToConnect(connectionFuture)); } }
/// <summary> /// Creates a <see cref="ReceptionistConfig"/> 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="ReceptionistConfig"/> instance.</returns> public static ReceptionistConfig CreateConnectionConfigFromCommandLine(Dictionary <string, string> parsedArgs) { var config = new ReceptionistConfig { ReceptionistHost = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.ReceptionistHost, RuntimeConfigDefaults.ReceptionistHost), ReceptionistPort = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.ReceptionistPort, RuntimeConfigDefaults.ReceptionistPort), LinkProtocol = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.LinkProtocol, RuntimeConfigDefaults.LinkProtocol), WorkerId = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.WorkerId, string.Empty), WorkerType = CommandLineUtility.GetCommandLineValue( parsedArgs, RuntimeConfigNames.WorkerType, string.Empty) }; return(config); }