Example #1
0
 private async void StartCheckingForLcuStart()
 {
     while (_noLcuRunning)
     {
         if (LeagueClient.GetLeagueClientProcesses().Length == 0)
         {
             await Task.Run(() => Thread.Sleep(30000));
         }
         else
         {
             _noLcuRunning = false;
             AcceptReadyChecks();
         }
     }
 }
Example #2
0
        private void AcceptReadyChecks()
        {
            foreach (var process in LeagueClient.GetLeagueClientProcesses())
            {
                var apiAuth = LeagueClient.GetApiPortAndToken(process);
                var ws      = new WebSocket($"wss://127.0.0.1:{apiAuth.Port}/", "wamp");
                ws.SetCredentials("riot", apiAuth.Token, true);
                ws.SslConfiguration.ServerCertificateValidationCallback = (send, certificate, chain, sslPolicyErrors) => true;
                ws.OnMessage += (s, e) =>
                {
                    if (!e.IsText || !_enabled)
                    {
                        return;
                    }

                    var eventArray  = JArray.Parse(e.Data);
                    var eventNumber = eventArray[0].ToObject <int>();

                    if (eventNumber != 8)
                    {
                        return;
                    }

                    var leagueEvent     = eventArray[2];
                    var leagueEventData = leagueEvent.Value <string>("data");

                    if (leagueEventData != "ReadyCheck")
                    {
                        return;
                    }

                    var result = LeagueClient.SendApiRequest(apiAuth, "POST", "/lol-matchmaking/v1/ready-check/accept", "");
                    Debug.WriteLine(result);
                };
                ws.Connect();
                ws.Send("[5, \"OnJsonApiEvent_lol-gameflow_v1_gameflow-phase\"]");
                ws.OnClose += (sender, args) =>
                {
                    _noLcuRunning = true;
                    StartCheckingForLcuStart();
                };
            }
        }