Esempio n. 1
0
        protected override ConnectionService GetConnectionService()
        {
            var commandLineArguments = Environment.GetCommandLineArgs();
            var commandLineArgs      = CommandLineUtility.ParseCommandLineArgs(commandLineArguments);

            if (commandLineArgs.ContainsKey(RuntimeConfigNames.SteamDeploymentTag) ||
                commandLineArgs.ContainsKey(RuntimeConfigNames.SteamTicket))
            {
                return(ConnectionService.Locator);
            }

            if (commandLineArgs.ContainsKey(RuntimeConfigNames.LoginToken))
            {
                return(commandLineArgs.ContainsKey(RuntimeConfigNames.PlayerIdentityToken)
                    ? ConnectionService.AlphaLocator
                    : ConnectionService.Locator);
            }

            return(ConnectionService.Receptionist);
        }
Esempio n. 2
0
        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);
            config.WorkerId = CommandLineUtility.GetCommandLineValue(
                parsedArgs, RuntimeConfigNames.WorkerId, string.Empty);
            config.WorkerType = CommandLineUtility.GetCommandLineValue(
                parsedArgs, RuntimeConfigNames.WorkerType, string.Empty);
            return(config);
        }
Esempio n. 3
0
        protected override AlphaLocatorConfig GetAlphaLocatorConfig(string workerType)
        {
            var commandLineArguments = Environment.GetCommandLineArgs();
            var commandLineArgs      = CommandLineUtility.ParseCommandLineArgs(commandLineArguments);

            return(new AlphaLocatorConfig
            {
                LocatorHost = CommandLineUtility.GetCommandLineValue(
                    commandLineArgs, RuntimeConfigNames.LocatorHost, RuntimeConfigDefaults.LocatorHost),
                LocatorParameters = new Alpha.LocatorParameters
                {
                    PlayerIdentity = new Alpha.PlayerIdentityCredentials
                    {
                        PlayerIdentityToken = CommandLineUtility.GetCommandLineValue(
                            commandLineArgs, RuntimeConfigNames.PlayerIdentityToken, string.Empty),
                        LoginToken = CommandLineUtility.GetCommandLineValue(
                            commandLineArgs, RuntimeConfigNames.LoginToken, string.Empty)
                    },
                },
            });
        }
Esempio n. 4
0
        protected override ConnectionParameters GetConnectionParameters(string workerType, ConnectionService service)
        {
            // UseExternalIp needs to be true when using the locator
            var useExternalIp = service == ConnectionService.Locator ||
                                service == ConnectionService.AlphaLocator ||
                                UseExternalIp;

            if (Application.isEditor)
            {
                return(new ConnectionParameters
                {
                    WorkerType = workerType,
                    Network =
                    {
                        ConnectionType = RuntimeConfigDefaults.LinkProtocol,
                        UseExternalIp  = useExternalIp,
                    },
                    EnableProtocolLoggingAtStartup = false,
                    DefaultComponentVtable = new ComponentVtable(),
                });
            }

            var commandLineArguments = Environment.GetCommandLineArgs();
            var commandLineArgs      = CommandLineUtility.ParseCommandLineArgs(commandLineArguments);
            var linkProtocol         = CommandLineUtility.GetCommandLineValue(
                commandLineArgs, RuntimeConfigNames.LinkProtocol, RuntimeConfigDefaults.LinkProtocol);

            return(new ConnectionParameters
            {
                WorkerType = CommandLineUtility.GetCommandLineValue(
                    commandLineArgs, RuntimeConfigNames.WorkerType, workerType),
                Network =
                {
                    ConnectionType = linkProtocol,
                    UseExternalIp  = useExternalIp,
                },
                EnableProtocolLoggingAtStartup = false,
                DefaultComponentVtable = new ComponentVtable()
            });
        }
Esempio n. 5
0
        /// <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);
        }