Ejemplo n.º 1
0
        protected override void OnMessage(MessageEventArgs e)
        {
            Console.WriteLine(e.Data);
            DataFetcher dataFetcher = new DataFetcher();

            LoLClient lol = new LoLClient();

            if (e.Data.Contains("#01"))
            {
                Send(lol.GetSummonerIdByName(e.Data.Substring(3)));
            }
            else if (e.Data.Contains("#04"))
            {
                // ↓ Tony, add here the method for ChampionStatisticsActivity
                //Send ($"#05{METHOD NAME)");
                string jsonChampStats = dataFetcher.ChampionStatsData(e.Data.Substring(3));
                Console.WriteLine(jsonChampStats);
                Send($"{jsonChampStats}");
            }
            else if (e.Data.Contains("#06"))
            {
                // ↓ Tony, add here the method for MatchHistory
                //Send ($"#07{METHOD NAME)");
                string jsonMatchesHistory = dataFetcher.MatchHistoryData(e.Data.Substring(3));
                Send($"{jsonMatchesHistory}");
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // INit DB
            //    Utility.LaunchDB();

            LoLClient lol = new LoLClient();

            lol.GetSummonerIdByName("Hades Underworld");
            //lol.GetSummonerMatchesById();
            lol.GetSummonerRankingById();
            lol.GetSummonerGamesById();

            LoLGTContext context = new LoLGTContext();

            //   context.
            //context.Matches.Add(lol.Matches);
            context.StatsRanking.Add(lol.Ranking);
            context.SummonerGames.Add(lol.SummonerGames);
            context.SaveChanges();
            DateTime timeAtSendToClients = new DateTime();
            DateTime timeNow             = new DateTime();
            // ↓ Connect to ipaddress:4649/SendData
            WebSocketServer wssv = new WebSocketServer(System.Net.IPAddress.Any, 4649);

#if DEBUG
            wssv.Log.Level = LogLevel.Trace;
#endif
            wssv.KeepClean    = true;
            wssv.WaitTime     = TimeSpan.FromSeconds(120);
            wssv.ReuseAddress = false;
            // ↓ Implement Server activies in SendData.cs
            wssv.AddWebSocketService <SendData>("/SendData");

            //     LoLClient lol = new LoLClient();

            Console.WriteLine();

            wssv.Start();
            timeAtSendToClients = DateTime.Now;

            string input = "";
            while (input != "stop")
            {
                //timeNow = DateTime.Now;
                //if (timeNow == timeAtSendToClients+TimeSpan.FromMinutes(5))
                //{
                //    // ↓ Tony add the data to send to the clients in SendData
                //    string dataToBroadcast = "";
                //    wssv.WebSocketServices["/SendData"].Sessions.Broadcast(dataToBroadcast);
                //}
                //if (input.Take(5).ToString().ToLower() == "send ")
                //{
                //    string dataToBroadcast = input.Skip(5).ToString();
                //    wssv.WebSocketServices["/SendData"].Sessions.Broadcast(dataToBroadcast);
                //}

                input = "";
                try
                {
                    input = ReaderForLoops.ReadLine(150000);
                }
                catch (TimeoutException)
                {
                    //Console.WriteLine("Next loop init");
                }
            }
            wssv.Stop();
        }