Exemple #1
0
        public void RequestCDNAuthToken(uint appid, uint depotid, string host, string cdnKey)
        {
            if (CDNAuthTokens.ContainsKey(cdnKey) || bAborted)
            {
                return;
            }

            if (!CDNAuthTokens.TryAdd(cdnKey, new TaskCompletionSource <SteamApps.CDNAuthTokenCallback>()))
            {
                return;
            }

            bool completed   = false;
            var  timeoutDate = DateTime.Now.AddSeconds(10);
            Action <SteamApps.CDNAuthTokenCallback> cbMethod = (cdnAuth) =>
            {
                completed = true;
                Log.Info("Got CDN auth token for {0} result: {1} (expires {2})", host, cdnAuth.Result, cdnAuth.Expiration);

                if (cdnAuth.Result != EResult.OK)
                {
                    Abort();
                    return;
                }

                CDNAuthTokens[cdnKey].TrySetResult(cdnAuth);
            };

            WaitUntilCallback(() =>
            {
                callbacks.Subscribe(steamApps.GetCDNAuthToken(appid, depotid, host), cbMethod);
            }, () => { return(completed || DateTime.Now >= timeoutDate); });
        }
Exemple #2
0
        public void RequestCDNAuthToken(uint depotid, string host)
        {
            if (CDNAuthTokens.ContainsKey(Tuple.Create(depotid, host)) || bAborted)
            {
                return;
            }

            bool completed = false;
            Action <SteamApps.CDNAuthTokenCallback> cbMethod = (cdnAuth) =>
            {
                completed = true;
                Console.WriteLine("Got CDN auth token for {0} result: {1}", host, cdnAuth.Result);

                if (cdnAuth.Result != EResult.OK)
                {
                    Abort();
                    return;
                }

                CDNAuthTokens[Tuple.Create(depotid, host)] = cdnAuth;
            };

            WaitUntilCallback(() =>
            {
                callbacks.Subscribe(steamApps.GetCDNAuthToken(depotid, host), cbMethod);
            }, () => { return(completed); });
        }
        public void RequestCDNAuthToken(uint appid, uint depotid, string host)
        {
            host = ResolveCDNTopLevelHost(host);
            var cdnKey = string.Format("{0:D}:{1}", depotid, host);

            if (CDNAuthTokens.ContainsKey(cdnKey) || bAborted)
            {
                return;
            }

            bool completed = false;
            Action <SteamApps.CDNAuthTokenCallback> cbMethod = (cdnAuth) =>
            {
                completed = true;
                Console.WriteLine("Got CDN auth token for {0} result: {1} (expires {2})", host, cdnAuth.Result, cdnAuth.Expiration);

                if (cdnAuth.Result != EResult.OK)
                {
                    Abort();
                    return;
                }

                CDNAuthTokens.TryAdd(cdnKey, cdnAuth);
            };

            WaitUntilCallback(() =>
            {
                callbacks.Subscribe(steamApps.GetCDNAuthToken(appid, depotid, host), cbMethod);
            }, () => { return(completed); });
        }
Exemple #4
0
        public Task <bool> RequestCDNAuthToken(uint appid, uint depotid, string host)
        {
            var tsc = new TaskCompletionSource <bool>();

            host = ResolveCDNTopLevelHost(host);
            var cdnKey = string.Format("{0:D}:{1}", depotid, host);

            if (CDNAuthTokens.ContainsKey(cdnKey) || bAborted)
            {
                tsc.SetResult(true);
                return(tsc.Task);
            }
            else
            {
                IDisposable subscription = null;
                Action <SteamApps.CDNAuthTokenCallback> cbMethod = (cdnAuth) =>
                {
                    subscription.Dispose();
                    DebugLog.WriteLine("Steam3Session", "Got CDN auth token for " + host + " result: " + cdnAuth.Result + " (expires " + cdnAuth.Expiration + ")");

                    if (cdnAuth.Result != EResult.OK)
                    {
                        Abort();
                        return;
                    }

                    CDNAuthTokens.TryAdd(cdnKey, cdnAuth);

                    tsc.SetResult(true);
                };

                subscription = callbacks.Subscribe(steamApps.GetCDNAuthToken(appid, depotid, host), cbMethod);
                return(tsc.Task);
            }
        }