Beispiel #1
0
        public static ACSMatchList GetMatchList(int startIndex, int endIndex)
        {
            String history     = "";
            String bearerToken = APIRequest.Instance.IDToken;

            Login.Session session;

            if (!Login.GetSession(out session))
            {
                return(null);
            }

            MatchHistory.GetMatchHistoryUrl(out history);

            String acsUrl;

            PlatformConfig.GetConfigSetting("LCUACS", "Endpoint", out acsUrl);
            String region;

            PlatformConfig.GetConfigSetting("LoginDataPacket", "platformId", out region);

            String url = String.Format("{0}/v1/stats/player_history/{1}/{2}?begIndex={3}&endIndex={4}",
                                       acsUrl, region, session.accountId, startIndex, endIndex);

            using (WebClient webClient = new WebClient())
            {
                webClient.Proxy = null; //Because otherwise downloads are slow
                webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)");
                webClient.Headers.Add("Bearer", bearerToken);
                webClient.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
                using (MemoryStream stream = new MemoryStream(webClient.DownloadData(url)))
                {
                    using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                    {
                        history = reader.ReadToEnd();
                    }
                }
            }
            ACSMatchList matchHistoryList = JsonHandler.LoadJson <ACSMatchList>(history);

            return(matchHistoryList);
        }
Beispiel #2
0
        private void ScanForGame()
        {
            while (running)
            {
                Thread.Sleep(1000);
                String error;
                //Find LeagueClient:
                FindGameResult findGameResult = _leagueClientMemoryEditor.FindGame("LeagueClientUx", out error, false);
                if (findGameResult != FindGameResult.GameFound)
                {
                    OnErrorCallback("League Client Not Open");
                    continue;
                }

                //Get Command Line for Password & Port
                String   Password    = "";
                Int32    Port        = 0;
                String   commandLine = _leagueClientMemoryEditor.GetCommandLine();
                String[] commands    = commandLine.Split(' ');
                foreach (String command in commands)
                {
                    if (command.Contains("--remoting-auth-token="))
                    {
                        Password = command.Replace("\"", "").Replace("--remoting-auth-token=", "");
                    }
                    else if (command.Contains("--app-port="))
                    {
                        Port = Convert.ToInt32(command.Replace("\"", "").Replace("--app-port=", ""));
                    }
                }

                //Check to see if the user is logged in
                if (!APIRequest.Instance.Setup("riot", Password, Port))
                {
                    OnErrorCallback("Not Logged In");
                    continue;
                }

                //Find the LeagueClient for remote calling
                findGameResult = _leagueClientMemoryEditor.FindGame("LeagueClient", out error, false);
                _leagueClientMemoryEditor.ProcessExitedHandler += OnProcessClosed;
                if (findGameResult != FindGameResult.GameFound)
                {
                    continue;
                }

                String region;
                if (PlatformConfig.GetConfigSetting("LoginDataPacket", "platformId", out region))
                {
                    _remoteLoLReplays = new RemoteLoLReplays(region);
                    OnLoginCallback();
                    running = false;
                }
                else
                {
                    //Actually check to see if they're logged in

                    /*Login.Session session;
                     * if(!Login.GetSession(out session))
                     *  OnErrorCallback("Error Requesting PlatformID");*/
                    OnErrorCallback("Logging In");
                }
            }
        }