Example #1
0
        public void RequestAppInfo(uint appId)
        {
            if (AppInfo.ContainsKey(appId) || bAborted)
                return;

            bool completed = false;
            Action<SteamApps.PICSTokensCallback> cbMethodTokens = (appTokens) =>
            {
                completed = true;
                if (appTokens.AppTokensDenied.Contains(appId))
                {
                    Console.WriteLine("Insufficient privileges to get access token for app {0}", appId);
                }

                foreach (var token_dict in appTokens.AppTokens)
                {
                    this.AppTokens.Add(token_dict.Key, token_dict.Value);
                }
            };

            WaitUntilCallback(() => {
                callbacks.Subscribe(steamApps.PICSGetAccessTokens(new List<uint>() { appId }, new List<uint>() { }), cbMethodTokens);
            }, () => { return completed; });

            completed = false;
            Action<SteamApps.PICSProductInfoCallback> cbMethod = (appInfo) =>
            {
                completed = !appInfo.ResponsePending;

                foreach (var app_value in appInfo.Apps)
                {
                    var app = app_value.Value;

                    Console.WriteLine("Got AppInfo for {0}", app.ID);
                    AppInfo.Add(app.ID, app);
                }

                foreach (var app in appInfo.UnknownApps)
                {
                    AppInfo.Add(app, null);
                }
            };

            SteamApps.PICSRequest request = new SteamApps.PICSRequest(appId);
            if (AppTokens.ContainsKey(appId))
            {
                request.AccessToken = AppTokens[appId];
                request.Public = false;
            }

            WaitUntilCallback(() => {
                callbacks.Subscribe(steamApps.PICSGetProductInfo(new List<SteamApps.PICSRequest>() { request }, new List<SteamApps.PICSRequest>() { }), cbMethod);
            }, () => { return completed; });
        }
        public void RequestAppInfo(uint appId)
        {
            if (AppInfo.ContainsKey(appId) || bAborted)
                return;

            bool appTokensCompleted = false;
            Action<SteamApps.PICSTokensCallback> cbMethodTokens = (appTokens) =>
            {
                if (appTokens.AppTokensDenied.Contains(appId))
                {
                    Console.WriteLine("Insufficient privileges to get access token for app {0}", appId);
                }

                foreach (var token_dict in appTokens.AppTokens)
                {
                    this.AppTokens.Add(token_dict.Key, token_dict.Value);
                }

                appTokensCompleted = true;
            };

            using (var appTokensCallback = new Callback<SteamApps.PICSTokensCallback>(cbMethodTokens, callbacks, steamApps.PICSGetAccessTokens(new List<uint>() { appId }, new List<uint>() { })))
            {
                do
                {
                    WaitForCallbacks();
                }
                while (!appTokensCompleted && !bAborted);
            }

            bool appInfoCompleted = false;
            Action<SteamApps.PICSProductInfoCallback> cbMethod = (appInfo) =>
            {
                Debug.Assert( appInfo.ResponsePending == false );

                foreach (var app_value in appInfo.Apps)
                {
                    var app = app_value.Value;

                    Console.WriteLine("Got AppInfo for {0}", app.ID);
                    AppInfo.Add(app.ID, app);
                }

                foreach (var app in appInfo.UnknownApps)
                {
                    AppInfo.Add(app, null);
                }

                appInfoCompleted = true;
            };

            SteamApps.PICSRequest request = new SteamApps.PICSRequest(appId);
            if (AppTokens.ContainsKey(appId))
            {
                request.AccessToken = AppTokens[appId];
                request.Public = false;
            }

            using (Callback<SteamApps.PICSProductInfoCallback> appInfoCallback = new Callback<SteamApps.PICSProductInfoCallback>(cbMethod, callbacks, steamApps.PICSGetProductInfo(new List<SteamApps.PICSRequest>() { request }, new List<SteamApps.PICSRequest>() { })))
            {
                do
                {
                    WaitForCallbacks();
                }
                while (!appInfoCompleted && !bAborted);
            }
        }
Example #3
0
        public void RequestAppInfo(uint appId)
        {
            if (AppInfo.ContainsKey(appId) || bAborted)
                return;

            Action<SteamApps.PICSTokensCallback, JobID> cbMethodTokens = (appTokens, jobId) =>
            {
                if (appTokens.AppTokensDenied.Contains(appId))
                {
                    Console.WriteLine("Insufficient privileges to get access token for app {0}", appId);
                }

                foreach (var token_dict in appTokens.AppTokens)
                {
                    this.AppTokens.Add(token_dict.Key, token_dict.Value);
                }
            };

            using (JobCallback<SteamApps.PICSTokensCallback> appTokensCallback = new JobCallback<SteamApps.PICSTokensCallback>(cbMethodTokens, callbacks, steamApps.PICSGetAccessTokens(new List<uint>() { appId }, new List<uint>() { })))
            {
                do
                {
                    WaitForCallbacks();
                }
                while (!appTokensCallback.Completed && !bAborted);
            }

            Action<SteamApps.PICSProductInfoCallback, JobID> cbMethod = (appInfo, jobId) =>
            {
                Debug.Assert( appInfo.ResponsePending == false );

                foreach (var app_value in appInfo.Apps)
                {
                    var app = app_value.Value;

                    Console.WriteLine("Got AppInfo for {0}", app.ID);
                    AppInfo.Add(app.ID, app);

                    KeyValue depots = ContentDownloader.GetSteam3AppSection((int)app.ID, EAppInfoSection.Depots);
                    if (depots != null)
                    {
                        if (depots["OverridesCDDB"].AsBoolean(false))
                        {
                            AppInfoOverridesCDR[app.ID] = true;
                        }
                    }
                }

                foreach (var app in appInfo.UnknownApps)
                {
                    AppInfo.Add(app, null);
                }
            };

            SteamApps.PICSRequest request = new SteamApps.PICSRequest(appId);
            if (AppTokens.ContainsKey(appId))
            {
                request.AccessToken = AppTokens[appId];
                request.Public = false;
            }

            using (JobCallback<SteamApps.PICSProductInfoCallback> appInfoCallback = new JobCallback<SteamApps.PICSProductInfoCallback>(cbMethod, callbacks, steamApps.PICSGetProductInfo(new List<SteamApps.PICSRequest>() { request }, new List<SteamApps.PICSRequest>() { })))
            {
                do
                {
                    WaitForCallbacks();
                }
                while (!appInfoCallback.Completed && !bAborted);
            }
        }
Example #4
0
        public void RequestAppInfo(uint appid, AppCallback callback)
        {
            // Callback for Application Information
            Action<SteamApps.PICSProductInfoCallback> AppCallback = (appinfo) =>
            {
                var returnData = appinfo.Apps.Where( x => x.Key == appid );
                if( returnData.Count() == 1 )
                {
                    // Return successful data
                    callback( returnData.First().Value );
                    return;
                }

                callback(null);
            };

            // Callback for Token
            Action<SteamApps.PICSTokensCallback> TokenCallback = (apptoken) =>
            {
                // Check if our token was returned
                var ourToken = apptoken.AppTokens.Where( x => x.Key == appid );
                if( ourToken.Count() != 1 ) return;

                // Use our token to request the app information
                var Request = new SteamApps.PICSRequest(appid)
                {
                    AccessToken = ourToken.First().Value,
                    Public = false
                };

                _CManager.Subscribe( _Apps.PICSGetProductInfo(new List<SteamApps.PICSRequest>() {Request}, new List<SteamApps.PICSRequest>()), AppCallback);
            };

            // Fire Token Callback
            _CManager.Subscribe(_Apps.PICSGetAccessTokens(new List<uint>() {appid}, new List<uint>()), TokenCallback);
        }