private static void addSummonerIDs(Configuration config) { PublicSummoner summ; List<SummonerCrawler> list = new List<SummonerCrawler>(); SummonerCrawler curSummoner; RiotConnect pvpnet = new RiotConnect(config, "wesa001", "baylife13"); DADatabase db = new DADatabase(); db.getTrackedSummoners(ref list); while (!pvpnet.Connected); for (int i = 0; i < list.Count; i++) { curSummoner = list.ElementAt(i); if (curSummoner.summonerId == 0 || curSummoner.accountId == 0) { if ((summ = pvpnet.RPC.GetSummonerByName(curSummoner.summonerName)) != null) { db.updateSummonerByName("summoner_id", summ.summonerId.ToString(), curSummoner.summonerName); db.updateSummonerByName("account_id", summ.acctId.ToString(), curSummoner.summonerName); Console.Out.WriteLine("ADDED SUMMONER = " + curSummoner.summonerName); } } } }
public CrawlWorkerData(Configuration config, List<SummonerCrawler> list, string user, string pass, string eUser, string ePass) { configuration = config; summonerList = list; loginUser = user; loginPass = pass; endLoginUser = eUser; endLoginPass = ePass; }
public RiotCrawl(Configuration config) { summonersList = new List<SummonerCrawler>(); db = new DADatabase(); if (db.getTrackedSummoners(ref summonersList)) { crawl(config); } }
public RiotConnect(Configuration configure, string username, string password) { proxy = new ProxyProfile(); //TODO: Make autowatch change based on input AutoWatch = false; config = configure; connectionData = new ConnectionProfile(config.Authentication, config.Region.RegionData, proxy, username, password); logPath = username + ".log"; Connect(); }
public EndGameWorker(ref Dictionary<string, InGameSummoner> iGS, ref List<string> keys, Configuration cfg, string endUser, string endPass) { logPath = endUser + ".log"; /** Clear log file */ File.WriteAllText(logPath, String.Empty); inGameSummoners = iGS; inGameKeys = keys; db = new DADatabase(); config = cfg; endLoginUser = endUser; endLoginPass = endPass; stopWaitHandle = new AutoResetEvent(false); gameUpdatedElsewhere = false; pvpnetReconnects = 0; endSummonerStats = new List<EndSummonerGameStats>(); endPSummoners = new List<PublicSummoner>(); endLifeStats = new List<PlayerLifeTimeStats>(); forceDC = false; }
/** Method to crawl PvPnet for all the summoners being crawled */ private static void crawlPvpnetss(Configuration config) { RiotConnect pvpnet; RiotChat chat; /** Persistent connection */ while (!forceDC) { /* Establish Connection to PvPNet */ pvpnet = new RiotConnect(config, "darkactivestats", "baylife13"); /** Wait for PvP.net Server connection */ if (waitForPvpnet(pvpnet)) { chat = new RiotChat("darkactivestats", "baylife13"); /* Initialise the PvPNet Crawler */ //RiotCrawl crawler = new RiotCrawl(pvpnet, chat); } } }
private static void crawlPvpnet(Configuration config) { RiotCrawl crawler = new RiotCrawl(config); }
private static void test(Configuration config) { RiotConnect pvpnet = new RiotConnect(config, "wesa001", "baylife13"); DADatabase db = new DADatabase(); while (!pvpnet.Connected); PublicSummoner summoner = pvpnet.RPC.summoner.GetSummonerByName("coupdegrace666"); PlatformGameLifecycleDTO game = pvpnet.RPC.game.retrieveInProgressSpectatorGameInfo("coupdegrace666"); db.addInProgressGame(game, summoner.summonerId); Console.Out.WriteLine("summ id: " + summoner.summonerId); while (1 == 1) ; }
private static void createMatch(Configuration config) { /** Initialize PvP.net Server Connection */ RiotConnect pvpnet = new RiotConnect(config, "wesa001", "baylife13"); RiotChat chat = new RiotChat("wesa001", "baylife13"); /** Wait for PvP.net Server to be connected */ while (!pvpnet.Connected) ; PublicSummoner mysumm = pvpnet.RPC.GetSummonerByName("wesa001"); PublicSummoner summ = pvpnet.RPC.GetSummonerByName("appak"); //GameDTO game = pvpnet.RPC.game.createPracticeGame(new PracticeGameConfig("WESA MATCH 1", "test")); GameDTO game = pvpnet.RPC.game.joinGame(433787973, "hello"); //Console.WriteLine("summ id " + summ.summonerId); chat.sendPresence(); chat.inviteSummoner(summ.summonerId, 433787973, 1); while (1 == 1) ; }
private void crawl(Configuration config) { int numThreads; int summNdx, thrStart; CrawlWorkerData curWorker; List<RiotLogin> riotLogins = new List<RiotLogin>(); List<RiotLogin> endRiotLogins = new List<RiotLogin>(); List<CrawlWorkerData> thrSummList = new List<CrawlWorkerData>(); List<SummonerCrawler> temp; List<Thread> _threads = new List<Thread>(); List<CrawlWorker> _workers = new List<CrawlWorker>(); float dTemp; CrawlWorker worker; Thread curThread; if (summonersList.Count < (MaxSummoners * 4)) { numThreads = 4; MaxSummoners = (summonersList.Count / 4) + 4; } else { dTemp = (summonersList.Count / float.Parse(MaxSummoners.ToString())); numThreads = int.Parse(Math.Ceiling(dTemp).ToString()); } db.getRiotLogins(ref riotLogins, ref endRiotLogins); if (numThreads > 5) numThreads = 5; summNdx = 0; for (int thr = 0; thr < numThreads; thr++) { thrStart = thr * MaxSummoners; temp = new List<SummonerCrawler>(); for (summNdx = thrStart; summNdx < (thrStart + MaxSummoners) && summNdx < summonersList.Count; summNdx++) { temp.Add(summonersList[summNdx]); } curWorker = new CrawlWorkerData(config, temp, riotLogins[thr].Username, riotLogins[thr].Password, endRiotLogins[thr].Username, endRiotLogins[thr].Password); thrSummList.Add(curWorker); riotLogins[thr].inUse = true; worker = new CrawlWorker(curWorker); curThread = new Thread(worker.doWork); _threads.Add(curThread); _workers.Add(worker); curThread.Start(); } Console.WriteLine("Number of threads: " + numThreads); Console.WriteLine("First Summ Thread 1: " + thrSummList.ElementAt(0).loginUser); //Console.WriteLine("First Summ Thread 2: " + thrSummList.ElementAt(1).loginUser); //Console.WriteLine("First Summ Thread 3: " + thrSummList.ElementAt(2).loginUser); int command; string lineRead; Console.Write("$ "); while ((command = Console.Read()) != 'q') { switch (command) { case 'p': lineRead = Console.ReadLine(); try { int thNum = int.Parse(lineRead); thNum = thNum - 1; if (thNum < _workers.Count) { if (_workers.ElementAt(thNum).pause) _workers.ElementAt(thNum).pause = false; else _workers.ElementAt(thNum).pause = true; } else { Console.WriteLine("Thread doesn't exist"); } } catch (Exception ex) { string e = ex.ToString(); Console.WriteLine("Invalid thread"); } break; case 'c': lineRead = Console.ReadLine(); try { int thNum = int.Parse(lineRead); thNum = thNum - 1; if (thNum < _workers.Count) { Console.WriteLine("Thread " + (thNum + 1) + " has " + _workers.ElementAt(thNum).summonerList.Count + " summoners."); } else { Console.WriteLine("Thread doesn't exist"); } } catch (Exception ex) { string e = ex.ToString(); Console.WriteLine("Invalid thread number"); } break; case 'l': lineRead = Console.ReadLine(); try { int thNum = int.Parse(lineRead); thNum = thNum - 1; if (thNum < _workers.Count) { Console.WriteLine("Thread " + (thNum + 1) + " has " + _workers.ElementAt(thNum).liveGames.Count + " live games."); } else { Console.WriteLine("Thread doesn't exist"); } } catch (Exception ex) { string e = ex.ToString(); Console.WriteLine("Invalid thread number"); } break; case 'd': lineRead = Console.ReadLine(); try { int count = 0; int thNum = int.Parse(lineRead); thNum = thNum - 1; if (thNum < _workers.Count) { List<string> keys = _workers.ElementAt(thNum).liveGameKeys; Dictionary<string, InGameSummoner> games = _workers.ElementAt(thNum).liveGames; for (int i = 0; i < keys.Count; i++) { if (games[keys.ElementAt(i)].gameCompleted) count++; } double pc = (count / keys.Count) * 100; int percent = int.Parse(Math.Ceiling(pc).ToString()); Console.WriteLine("Thread " + (thNum + 1) + " has " + count + " completed games ( " + percent + " )."); } else { Console.WriteLine("Thread doesn't exist"); } } catch (Exception ex) { string e = ex.ToString(); Console.WriteLine("Invalid thread number"); } break; default: Console.ReadLine(); break; } Console.Write("$ "); } Console.WriteLine("Program terminating..."); Console.WriteLine("Goodbye!"); }