Beispiel #1
0
        /// <summary>
        /// Callback will be called when the avatar is ready. If we fail to get an
        /// avatar, might be called with a null Image.
        /// </summary>
        public void GetAvatar(AvatarSize size, ulong steamid, Action <Image> callback)
        {
            // Maybe we already have it downloaded?
            var image = GetCachedAvatar(size, steamid);

            if (image != null)
            {
                callback(image);
                return;
            }

            // Lets request it from Steam
            if (!client.native.friends.RequestUserInformation(steamid, false))
            {
                // Steam told us to get f****d
                callback(null);
                return;
            }

            PersonaCallbacks.Add(new PersonaCallback
            {
                SteamId  = steamid,
                Size     = size,
                Callback = callback,
                Time     = DateTime.Now
            });
        }
Beispiel #2
0
        /// <summary>
        /// Callback will be called when the avatar is ready. If we fail to get an
        /// avatar, might be called with a null Image.
        /// </summary>
        public void GetAvatar(AvatarSize size, ulong steamid, Action <Image> callback)
        {
            // Maybe we already have it downloaded?
            var image = GetCachedAvatar(size, steamid);

            if (image != null)
            {
                callback(image);
                return;
            }

            // Lets request it from Steam
            if (!client.native.friends.RequestUserInformation(steamid, false))
            {
                // from docs: false means that we already have all the details about that user, and functions that require this information can be used immediately
                // but that's probably not true because we just checked the cache

                // check again in case it was just a race
                image = GetCachedAvatar(size, steamid);
                if (image != null)
                {
                    callback(image);
                    return;
                }

                // maybe Steam returns false if it was already requested? just add another callback and hope it comes
                // if not it'll time out anyway
            }

            PersonaCallbacks.Add(new PersonaCallback
            {
                SteamId  = steamid,
                Size     = size,
                Callback = callback,
                Time     = DateTime.Now
            });
        }