public PlayFabGameServer(IServerTransportLayer transportLayer, PlayFabServerSettingsData serverSettings) : base(transportLayer)
        {
            Debug.Assert(serverSettings != null, "Server Settings Must Not Be Null!");

            this.serverSettings = serverSettings;

            PlayFabSettings.DeveloperSecretKey = serverSettings.TitleSecretKey;
            PlayFabSettings.TitleId            = serverSettings.TitleId;
        }
        /// <summary>
        /// When playfab launches a game instance it passing all needed data via the command
        /// line.  This wraps up all that data into a ServerSettingsData instance.
        /// </summary>
        public static PlayFabServerSettingsData GetServerDataFromCommandLine()
        {
            var data = new PlayFabServerSettingsData();

            data.IsExternalServer = false;
            data.Tags             = null;

            foreach (string arg in System.Environment.GetCommandLineArgs())
            {
                string[] argArray = arg.Split('=');

                if (argArray.Length < 2)
                {
                    continue;
                }

                var key   = argArray[0].Contains("-") ? argArray[0].Replace("-", string.Empty).Trim() : argArray[0].Trim();
                var value = argArray[1].Trim();

                switch (key.ToLower())
                {
                // playfab data
                case "title_secret_key":
                {
                    data.TitleSecretKey = value;
                    break;
                }

                case "playfab_api_endpoint":
                {
                    data.PlayFabApiEndpoint = value;

                    // Ex: https://87a6.playfabapi.com:443
                    string removedHttps = value.ToLower().Replace("https://", string.Empty);
                    int    firstDot     = removedHttps.IndexOf('.');
                    data.TitleId = removedHttps.Substring(0, firstDot);

                    break;
                }

                case "game_id":
                {
                    data.LobbyId = value;
                    break;
                }

                // server data
                case "server_host_domain":
                {
                    data.ServerHostDomain = value;
                    break;
                }

                case "server_host_port":
                {
                    int defaultHostPort = 7777;
                    int hostPort        = 0;

                    if (int.TryParse(value, out hostPort) == false)
                    {
                        Debug.LogErrorFormat("PlayFabGameServer: Unable to parse server_host_port {0}, using {1} instead.  This may break your game.", value, defaultHostPort);
                    }

                    data.ServerHostPort = hostPort > 0 ? hostPort : defaultHostPort;
                    break;
                }

                case "server_host_region":
                {
                    data.ServerHostRegion = (Region)Enum.Parse(typeof(Region), value);
                    break;
                }

                // game mode data
                case "game_mode":
                {
                    data.GameMode = value;
                    break;
                }

                case "game_build_version":
                {
                    data.GameBuildVersion = value;
                    break;
                }

                case "custom_data":
                {
                    data.CustomData = value;
                    break;
                }

                // logging data
                case "log_file_path":
                {
                    data.LogFilePath = value;
                    break;
                }

                case "output_files_directory_path":
                {
                    data.OutputFilesDirectory = value;
                    break;
                }
                }
            }

            return(data);
        }