예제 #1
0
        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);
                    }
                }
            }
        }
예제 #2
0
        public void doWork()
        {
            /** Persistent connection */
            while (!forceDC)
            {
                /* Establish Connection to PvPNet */
                pvpnet = new RiotConnect(data.configuration, data.loginUser, data.loginPass);

                /** Wait for PvP.net Server connection */
                if (waitForPvpnet(pvpnet))
                {
                    /* Initialise the PvPNet Crawler */
                    crawlPvpnet();
                }
            }
        }
예제 #3
0
        /** 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);
                }
            }
        }
예제 #4
0
        /** Method to wait for connection or keep trying reconnect */
        private static bool waitForPvpnet(RiotConnect pvpnet)
        {
            int time = 0;

            while (!pvpnet.Connected && time < RECFREQ)
            {
                Thread.Sleep(1000);
                time++;
            }

            if (time >= RECFREQ)
                return false;

            return true;
        }
예제 #5
0
        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) ;
        }
예제 #6
0
        static void Main(string[] args)
        {
            // Set disconnect to false, to enable connection
            forceDC = false;

            //Database db;
            Configuration configuration;
            try
            {
                Serialiser<Configuration> serialiser = new Serialiser<Configuration>(ConfigurationFile);
                configuration = serialiser.Load();
            }
            catch (System.IO.FileNotFoundException)
            {
                Console.WriteLine("Unable to load configuration file \"" + ConfigurationFile + "\"");
                return;
            }
            catch (System.InvalidOperationException)
            {
                Console.WriteLine("Malformed configuration file");
                return;
            }

            // Check argument for program mode
            if (args.Length != 0)
            {
                switch (args[0])
                {
                    case "crawl":
                        crawlPvpnet(configuration);
                    break;

                    case "creatematch":
                        createMatch(configuration);
                    break;
                    case "addsummonerids":
                        addSummonerIDs(configuration);
                    break;
                    case "test":
                        test(configuration);
                    break;

                    case "test2":
                        RiotConnect pvpnet = new RiotConnect(configuration, "endwesa005", "baylife13");

                        while (!pvpnet.Connected) ;

                        List<long> fellows = new List<long>();
                        List<string> fellowNames = new List<string>();
                        RecentGames game = pvpnet.RPC.GetRecentGames(34022924);

                        for (int i = 0; i < game.gameStatistics.Count; i++)
                        {
                            if (game.gameStatistics.ElementAt(i).gameId == 675775152)
                            {
                                for (int j = 0; j < game.gameStatistics.ElementAt(i).fellowPlayers.Count; j++)
                                {
                                    fellows.Add(game.gameStatistics.ElementAt(i).fellowPlayers.ElementAt(j).summonerId);
                                }
                                break;
                            }
                        }

                        fellowNames = pvpnet.RPC.GetSummonerNames(fellows);
                        PublicSummoner summoner;
                        RecentGames gameStats;

                        for (int n = 0; n < fellowNames.Count; n++)
                        {
                            summoner = pvpnet.RPC.GetSummonerByName(fellowNames.ElementAt(n));
                            gameStats = pvpnet.RPC.GetRecentGames(summoner.acctId);

                            if (gameStats == null)
                                Console.WriteLine(summoner.internalName + " PROBLEM = NULL");
                            else
                                Console.WriteLine(summoner.internalName + " recent Games successful");
                        }

                        while (1 == 1) ;

                    break;

                }
            }
        }
예제 #7
0
        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) ;
        }
예제 #8
0
        public void doWork()
        {
            int ndx;
            double lastPrint = 0;
            double startTime;
            RecentGames recGames;
            InGameSummoner liveGame;
            int i;

            while (!forceDC)
            {
                pvpnet = new RiotConnect(config, endLoginUser, endLoginPass);

                if (waitForPvpnet(pvpnet))
                {
                    while (pvpnet.Connected)
                    {
                        for (ndx = 0; ndx < inGameKeys.Count && pvpnet.Connected; ndx++)
                        {
                            liveGame = inGameSummoners[inGameKeys.ElementAt(ndx)];
                            // Game Completed, begin end game stats
                            // TODO make sure this is fixed with check for null
                            if (liveGame != null && liveGame.gameCompleted)
                            {
                                ConsoleOut("GameUpdate: Game completed and updating started - ID = " + liveGame.summonerCr.lastGameId);
                                startTime = getUnixTimestamp();
                                startEndGameStats(liveGame.summonerCr);

                                if (stopWaitHandle.WaitOne(MAXWAITASYNC))
                                {
                                    // This is a boolean that specifies if other thread updated End game
                                    if (!gameUpdatedElsewhere)
                                        finishEndGameStats();

                                    gameUpdatedElsewhere = false;
                                    inGameSummoners.Remove(inGameKeys.ElementAt(ndx));
                                    inGameKeys.RemoveAt(ndx);
                                }
                                else
                                {
                                    // On 2 timeouts, remove all game entries from database and add as an old game.
                                    if (liveGame.timedOut)
                                    {
                                        db.removeLiveGame(liveGame.summonerCr.lastGameId);
                                        db.removePreGame(liveGame.summonerCr.lastGameId);

                                        // Sort recent games and add correct to DB
                                        // TODO: null object error recGames
                                        recGames = pvpnet.RPC.GetRecentGames(liveGame.summonerCr.accountId);
                                        recGames.gameStatistics.Sort(CompareGames);
                                        for (i = 0; i < recGames.gameStatistics.Count; i++)
                                        {
                                            if (recGames.gameStatistics.ElementAt(i).gameId == liveGame.summonerCr.lastGameId)
                                            {
                                                if (!db.gameStatsExists(liveGame.summonerCr.lastGameId))
                                                {
                                                    db.addOldGame(recGames.gameStatistics.ElementAt(i), liveGame.summonerCr.accountId);
                                                    break;
                                                }
                                            }
                                        }
                                        inGameSummoners.Remove(inGameKeys.ElementAt(ndx));
                                        inGameKeys.RemoveAt(ndx);
                                    }

                                    liveGame.timedOut = true;
                                    ConsoleOut("TIMEOUT: Timedout on game update");
                                }
                            }

                            if (getUnixTimestamp() - lastPrint >= 10)
                            {
                                ConsoleOut("...... " + inGameSummoners.Count);
                                lastPrint = getUnixTimestamp();
                            }
                        }
                    }
                    pvpnetReconnects++;
                }
            }
        }