Exemplo n.º 1
0
        /// <summary>
        /// Returns the user's public profile information associated with the given unique indentifier using the specified <see cref="HHotel"/> in an asynchronous operation.
        /// </summary>
        /// <param name="uniqueId">The unique identifier of the user.</param>
        /// <param name="hotel">The hotel where the target user is from.</param>
        public static async Task <HProfile> GetProfileByUniqueIdAsync(string uniqueId, HHotel hotel)
        {
            using (var client = new WebClient())
            {
                client.Proxy = null;
                client.Headers[HttpRequestHeader.UserAgent] = ChromeAgent;
                client.Headers.Add(HttpRequestHeader.Cookie, "YPF8827340282Jdskjhfiw_928937459182JAX666=127.0.0.1");

                string profileJson = null;
                try
                {
                    profileJson = await client.DownloadStringTaskAsync(string.Format(PROFILE_API_FORMAT, hotel.ToUrl(true), uniqueId)).ConfigureAwait(false);
                }
                catch (WebException ex)
                {
                    using (WebResponse response = ex.Response)
                        using (var responseReader = new StreamReader(response.GetResponseStream()))
                        {
                            profileJson = await responseReader.ReadToEndAsync().ConfigureAwait(false);
                        }
                }
                if (profileJson.StartsWith("{\"error"))
                {
                    return(null);
                }
                return(HProfile.Create(profileJson));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the <seealso cref="HProfile"/> from the specified hotel associated with the given unique identifier in an asynchronous operation.
        /// </summary>
        /// <param name="uniqueId">The unique identifier of the player you wish to retrieve the <see cref="HProfile"/> from.</param>
        /// <param name="hotel">The <seealso cref="HHotel"/> that the target user is located on.</param>
        /// <returns></returns>
        public static async Task <HProfile> GetProfileAsync(string uniqueId, HHotel hotel)
        {
            string profileJson = await _httpClient.GetStringAsync(
                string.Format(PROFILE_API_FORMAT, hotel.ToUrl(), uniqueId));

            return(HProfile.Create(profileJson));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the user's public profile information associated with the given unique indentifier using the specified <see cref="HHotel"/> in an asynchronous operation.
        /// </summary>
        /// <param name="uniqueId">The unique identifier of the user.</param>
        /// <param name="hotel">The hotel where the target user is from.</param>
        public static async Task <HProfile> GetProfileByUniqueIdAsync(string uniqueId, HHotel hotel)
        {
            string profileJson = await _hRequest.DownloadStringAsync(
                string.Format(PROFILE_API_FORMAT, hotel.ToUrl(true), uniqueId)).ConfigureAwait(false);

            return(HProfile.Create(profileJson));
        }
Exemplo n.º 4
0
        public async Task <HProfile> GetProfileAsync(string name, HHotel hotel)
        {
            if (!_profileCache.ContainsKey(hotel))
            {
                _profileCache[hotel] = new Dictionary <string, HProfile>();
            }

            if (!_profileCache[hotel].ContainsKey(name))
            {
                HProfile profile = await SKore.GetProfileAsync(
                    name, hotel).ConfigureAwait(false);

                _profileCache[hotel][name] = profile;
            }
            return(_profileCache[hotel][name]);
        }
Exemplo n.º 5
0
        public async Task <HProfile> GetProfileAsync(AuthorAttribute authorAtt)
        {
            if (!_profileCache.ContainsKey(authorAtt.Hotel))
            {
                _profileCache[authorAtt.Hotel] = new Dictionary <string, HProfile>();
            }

            if (_profileCache[authorAtt.Hotel]
                .ContainsKey(authorAtt.HabboName))
            {
                return(_profileCache[authorAtt.Hotel][authorAtt.HabboName]);
            }

            HProfile profile = await SKore.GetProfileAsync(
                authorAtt.HabboName, authorAtt.Hotel).ConfigureAwait(false);

            _profileCache[authorAtt.Hotel][authorAtt.HabboName] = profile;
            return(profile);
        }
Exemplo n.º 6
0
        public async Task <Bitmap> GetAvatarAsync(string name, HHotel hotel)
        {
            HProfile profile = await GetProfileAsync(
                name, hotel).ConfigureAwait(false);

            if (profile == null)
            {
                return(Resources.Avatar);
            }

            if (!_avatarCache.ContainsKey(profile.User.FigureId))
            {
                Bitmap avatar = await SKore.GetAvatarAsync(
                    profile.User.FigureId, HSize.Medium).ConfigureAwait(false);

                _avatarCache[profile.User.FigureId] = avatar;
            }
            return(_avatarCache[profile.User.FigureId]);
        }
Exemplo n.º 7
0
        public async Task <Bitmap> GetAvatarAsync(AuthorAttribute authorAtt)
        {
            HProfile profile = await GetProfileAsync(
                authorAtt).ConfigureAwait(false);

            if (profile == null)
            {
                return(Resources.Avatar);
            }

            if (_avatarCache.ContainsKey(profile.User.FigureId))
            {
                return(_avatarCache[profile.User.FigureId]);
            }

            Bitmap avatar = await SKore.GetAvatarAsync(
                profile.User.FigureId, HSize.Medium).ConfigureAwait(false);

            _avatarCache[profile.User.FigureId] = avatar;
            return(avatar);
        }