예제 #1
0
 protected SdkService(ISdkConfig config)
 {
     Config                = config;
     HttpHelper            = new HttpHelper(config.Gateway);
     HttpHelper.OnRequest += BeforeRequest;
     HttpHelper.OnResult  += OnResult;
 }
예제 #2
0
 protected SdkService(ISdkConfig config, IHttpContextAccessor contextAccessor)
 {
     Config                = config;
     HttpHelper            = new HttpHelper(config.Gateway);
     HttpHelper.OnRequest += BeforeRequest;
     HttpHelper.OnResult  += OnResult;
     ContextAccessor       = contextAccessor;
 }
        public ConfigStatus ToLaunchGameRequest(
            LaunchParams parameters, out LaunchGameRequest request)
        {
            ConfigStatus status =
                _queryParametersParser.ParametersToDictionary(
                    parameters.QueryParams, out IDictionary <string, string> parametersDict);

            status = status.Merge(
                _queryParametersParser.ParseToParameters(parametersDict, parameters));
            ISdkConfig sdkConfig = _sdkConfigFactory.LoadGgpSdkConfigOrDefault();

            status = status.Merge(
                EnvironmentVariables(parameters, out IDictionary <string, string> envVariables));
            status = status.Merge(CommandLineArguments(parameters, out string[] cmdArgs));

            if ((parameters.Endpoint == StadiaEndpoint.PlayerEndpoint ||
                 parameters.Endpoint == StadiaEndpoint.AnyEndpoint) &&
                !string.IsNullOrEmpty(parameters.TestAccount))
            {
                status.AppendWarning(
                    ErrorStrings.TestAccountsNotSupported(parameters.TestAccountGamerName));
                parameters.TestAccount = null;
            }

            request = new LaunchGameRequest
            {
                Parent                   = Parent(sdkConfig, parameters),
                GameletName              = parameters.GameletName,
                ApplicationName          = parameters.ApplicationName,
                ExecutablePath           = ExecutablePath(parameters),
                CommandLineArguments     = cmdArgs,
                EnvironmentVariablePairs = envVariables,
                SurfaceEnforcementMode   = parameters.SurfaceEnforcementMode,
                Debug = parameters.Debug,
                EnableDeveloperResumeOffer = parameters.Endpoint == StadiaEndpoint.AnyEndpoint
            };

            status = status.Merge(
                _queryParametersParser.ParseToLaunchRequest(parametersDict, request));

            status = status.Merge(
                _queryParametersParser.GetFinalQueryString(parametersDict, out string queryString));
            parameters.QueryParams = queryString;

            if ((parameters.Endpoint == StadiaEndpoint.PlayerEndpoint ||
                 parameters.Endpoint == StadiaEndpoint.AnyEndpoint) &&
                !string.IsNullOrEmpty(queryString))
            {
                status.AppendWarning(ErrorStrings.QueryParamsNotSupported(queryString));
            }

            return(status);
        }
 string Parent(ISdkConfig sdkConfig, LaunchParams parameters) =>
 string.IsNullOrWhiteSpace(parameters.TestAccount)
         ? _developerLaunchGameParent
         : parameters.TestAccount;