Пример #1
0
        private Task <bool> RequestPICSProductInfo(uint appId)
        {
            var tsc = new TaskCompletionSource <bool>();

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

            IDisposable subscription = null;
            Action <SteamApps.PICSProductInfoCallback> cbMethod = (appInfo) =>
            {
                subscription.Dispose();
                foreach (var app_value in appInfo.Apps)
                {
                    var app = app_value.Value;

                    DebugLog.WriteLine("Steam3Session", "Got AppInfo for " + app.ID);
                    if (AppInfo.ContainsKey(app.ID))
                    {
                        DebugLog.WriteLine("Steam3Session", "AppInfo already stored " + app.ID);
                        continue;
                    }
                    AppInfo.Add(app.ID, app);
                }

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

                DebugLog.WriteLine("Steam3Session", "Response pending: " + appInfo.ResponsePending);
                tsc.SetResult(!appInfo.ResponsePending);
            };

            subscription = callbacks.Subscribe(steamApps.PICSGetProductInfo(new List <SteamApps.PICSRequest>()
            {
                request
            }, new List <SteamApps.PICSRequest>()
            {
            }), cbMethod);

            return(tsc.Task);
        }
Пример #2
0
        public async Task RequestAppInfo(uint appId)
        {
            if (!AppInfo.ContainsKey(appId) && !bAborted)
            {
                int  retries           = 0;
                bool appTokensReceived = false;
                while (!bAborted && !appTokensReceived && retries++ < 5)
                {
                    appTokensReceived = await RequestAppTokens(appId);
                }

                retries = 0;
                bool productInfoReceived = false;
                while (!bAborted && !productInfoReceived && retries++ < 5)
                {
                    productInfoReceived = await RequestPICSProductInfo(appId);
                }
            }
        }
Пример #3
0
 public override void InitializeFromXml(XElement e)
 {
     e = e.Element("appinfo");
     if (null != e)
     {
         var dict = e.ToDict();
         if (null == AppInfo)
         {
             AppInfo = dict;
         }
         else
         {
             foreach (var o in dict)
             {
                 if (!AppInfo.ContainsKey(o.Key))
                 {
                     AppInfo[o.Key] = o.Value;
                 }
             }
         }
     }
 }
Пример #4
0
        public void RequestAppInfo(uint appId)
        {
            if (AppInfo.ContainsKey(appId) || bAborted)
            {
                return;
            }

            Action <SteamApps.AppInfoCallback, JobID> cbMethod = (appInfo, jobId) =>
            {
                foreach (var app in appInfo.Apps)
                {
                    Console.WriteLine("Got AppInfo for {0}: {1}", app.AppID, app.Status);
                    AppInfo.Add(app.AppID, app);

                    if (app.Status == SteamApps.AppInfoCallback.App.AppInfoStatus.Unknown)
                    {
                        continue;
                    }

                    KeyValue depots;
                    if (app.Sections.TryGetValue(EAppInfoSection.Depots, out depots))
                    {
                        if (depots[app.AppID.ToString()]["OverridesCDDB"].AsBoolean(false))
                        {
                            AppInfoOverridesCDR[app.AppID] = true;
                        }
                    }
                }
            };

            using (JobCallback <SteamApps.AppInfoCallback> appInfoCallback = new JobCallback <SteamApps.AppInfoCallback>(cbMethod, callbacks, steamApps.GetAppInfo(appId)))
            {
                do
                {
                    WaitForCallbacks();
                }while (!appInfoCallback.Completed && !bAborted);
            }
        }
Пример #5
0
        public void RequestAppInfo(uint appId, bool bForce = false)
        {
            if ((AppInfo.ContainsKey(appId) && !bForce) || bAborted)
            {
                return;
            }

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

                foreach (var token_dict in appTokens.AppTokens)
                {
                    this.AppTokens[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;

                    Log.Info("Got AppInfo for {0}", app.ID);
                    AppInfo[app.ID] = app;
                }

                foreach (var app in appInfo.UnknownApps)
                {
                    AppInfo[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); });
        }
Пример #6
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);
                }

                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);
            }
        }