コード例 #1
0
        protected virtual ReceptionistConfig GetReceptionistConfig(string workerType)
        {
            ReceptionistConfig config;

            if (Application.isEditor)
            {
                config = new ReceptionistConfig
                {
                    WorkerType    = workerType,
                    WorkerId      = $"{workerType}-{Guid.NewGuid()}",
                    UseExternalIp = UseExternalIp
                };
            }
            else
            {
                var commandLineArguments = Environment.GetCommandLineArgs();
                var commandLineArgs      = CommandLineUtility.ParseCommandLineArgs(commandLineArguments);
                config = ReceptionistConfig.CreateConnectionConfigFromCommandLine(commandLineArgs);
                config.UseExternalIp = UseExternalIp;
                if (!commandLineArgs.ContainsKey(RuntimeConfigNames.WorkerId))
                {
                    config.WorkerId = $"{workerType}-{Guid.NewGuid()}";
                }
            }

            return(config);
        }
コード例 #2
0
        public void CreateConnectionConfigFromCommandLine_should_provide_defaults_for_missing_values()
        {
            var parsedArgs = new Dictionary <string, string>();
            var config     = ReceptionistConfig.CreateConnectionConfigFromCommandLine(parsedArgs);

            Assert.AreEqual(RuntimeConfigDefaults.ReceptionistHost, config.ReceptionistHost);
            Assert.AreEqual(RuntimeConfigDefaults.ReceptionistPort, config.ReceptionistPort);
            Assert.AreEqual(RuntimeConfigDefaults.LinkProtocol, config.LinkProtocol);
        }
コード例 #3
0
        public void CreateConnectionConfigFromCommandLine_should_parse_correctly()
        {
            const string host        = "myhost";
            const short  port        = 10;
            var          networkType = NetworkConnectionType.Tcp.ToString();

            var parsedArgs = new Dictionary <string, string>
            {
                { RuntimeConfigNames.ReceptionistHost, host },
                { RuntimeConfigNames.ReceptionistPort, port.ToString() },
                { RuntimeConfigNames.LinkProtocol, networkType }
            };

            var config = ReceptionistConfig.CreateConnectionConfigFromCommandLine(parsedArgs);

            Assert.AreEqual(host, config.ReceptionistHost);
            Assert.AreEqual(port, config.ReceptionistPort);
            Assert.AreEqual(networkType, config.LinkProtocol.ToString());
        }