Ejemplo n.º 1
0
        public List <Game> GetOwnedGames(string steamId)
        {
            var req      = SteamWebAPI.CustomRequest("IPlayerService", "GetOwnedGames", "v0001", new { steamid = steamId, include_appinfo = 1, include_played_free_games = 1 });
            var response = _HandleResponse <HttpGetOwnedGamesResponse>(req);

            //return response.Response.Games;

            if (response.Response.Games == null)
            {
                return(null);
            }

            //var repo = new MongoRepository<AppDetails>();

            //foreach (var game in response.Response.Games)
            //{
            //    if (!repo.Exists(x => x.AppId == game.Appid))
            //    {
            //        var appDetails = GetAppDetails(game.Appid);
            //        repo.Insert(appDetails);

            //    }


            //}

            return(response.Response.Games);
        }
Ejemplo n.º 2
0
        public List <Game> GetRecentGames(string steamId)
        {
            var req = SteamWebAPI.CustomRequest("IPlayerService", "GetRecentlyPlayedGames", "v0001", new { steamid = steamId });

            var response = _HandleResponse <HttpRecentlyPlayedGames>(req);

            return(response.Response.Games);
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetAllGames()
        {
            var req = SteamWebAPI.CustomRequest("ISteamApps", "GetAppList", "v2", new { });

            var responseString = req.GetResponseString(RequestFormat.JSON);


            return(Ok(responseString));
        }
Ejemplo n.º 4
0
        public IHttpActionResult GetRecentGames(string steamId)
        {
            var req = SteamWebAPI.CustomRequest("IPlayerService", "GetRecentlyPlayedGames", "v0001", new { steamid = steamId });

            var responseString = req.GetResponseString(RequestFormat.JSON);


            return(Ok(responseString));
        }
Ejemplo n.º 5
0
        public List <Player> GetFriends(string steamId)
        {
            var req      = SteamWebAPI.CustomRequest("ISteamuser", "GetFriendList", "v0001", new { steamId = steamId, relationship = "friend" });
            var response = _HandleResponse <HttpFriendListResponse>(req);


            var steamIds = response.Friendslist.Friends.Select(x => x.Steamid).ToArray();
            var users    = GetUsers(steamIds);

            return(users);
        }
Ejemplo n.º 6
0
        public List <Player> GetUsers(string[] steamIds)
        {
            var sSteamIds = "";
            var t         = steamIds.ToString();

            foreach (var id in steamIds)
            {
                sSteamIds += id + ",";
            }
            var req      = SteamWebAPI.CustomRequest("ISteamUser", "GetPlayerSummaries", "v0002", new { steamids = sSteamIds });
            var response = _HandleResponse <HttpUserResponse>(req);

            return(response.Response.Players.ToList());
        }
Ejemplo n.º 7
0
        public string GetSteamId(string username)
        {
            var req = SteamWebAPI.CustomRequest("ISteamUser", "ResolveVanityURL", "v0001", new { vanityurl = username });

            var result = _HandleResponse <HttpGetVanityUrlResponse>(req);

            if (result == null || result.Response.SteamId == null)
            {
                throw new Exception("Unable to convert to Valid SteamID");
            }


            return(result.Response.SteamId);
        }
Ejemplo n.º 8
0
        public Player GetUser(string steamId, string ip)
        {
            var repo = new MongoRepository <UserQuery>();

            Player dbPlayer = null;

            if (!Util.isValidSteamId(steamId))                                                                    // before we send this SteamID up in the request we check if its even in a valid format
            {
                dbPlayer = repo.Get <Player>(x => x.Personaname.ToLower() == steamId.ToLower()).FirstOrDefault(); // do we have a record of that in our DB

                if (dbPlayer != null)
                {
                    steamId = dbPlayer.Steamid; // Found it.
                }
                else
                {
                    steamId = GetSteamId(steamId); // no Go Request it from Steam
                }
            }


            var req      = SteamWebAPI.CustomRequest("ISteamUser", "GetPlayerSummaries", "v0002", new { steamids = steamId });
            var response = _HandleResponse <HttpUserResponse>(req);



            var query = new UserQuery()
            {
                SteamId     = steamId,
                IpAddress   = ip,
                DateCreated = DateTime.Now
            };

            repo.Insert(query);

            var player = response.Response.Players.First(); // get the player object from Steam

            if (!repo.Exists <Player>(x => x.Steamid == steamId))
            {
                // do we already have a record in the DB for this user
                player.OwnedGames = GetOwnedGames(player.Steamid);
                repo.Insert(player); // Nope, insert them
            }
            else
            {
                dbPlayer = dbPlayer ?? repo.Get <Player>(x => x.Steamid == steamId).FirstOrDefault(); // get the Player from the DB.

                // has the user changed their display name
                if (player.Personaname != dbPlayer.Personaname)
                {
                    dbPlayer.Personaname = player.Personaname;
                    repo.Update(dbPlayer);
                }
            }



            // have we got this player Already


            return(player);
        }