예제 #1
0
        private async Task WaitForPeopleToLeave(int minimumPeople)
        {
            if (minimumPeople < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(minimumPeople));
            }
            if (meetBot.State != MeetState.InCall)
            {
                throw new Exception("Not in call");
            }

            await Task.Delay(new TimeSpan(0, minutes : 5, 0), token);

            logger?.Debug("Starting exit loop...");

            while (true)
            {
                int peopleInCall = -1;
                while (peopleInCall == -1)
                {
                    try
                    {
                        peopleInCall = meetBot.PeopleInMeet();
                    }
                    catch (OpenQA.Selenium.NoSuchElementException)
                    {
                        logger?.Debug("Failed to fetch people in meet");
                    }
                    catch (OpenQA.Selenium.WebDriverTimeoutException)
                    {
                        break;
                    }
                }

                if (peopleInCall < minimumPeople)
                {
                    logger?.Debug("Leaving at {0} people", peopleInCall);
                    break;
                }

                await Task.Delay(new TimeSpan(0, 0, seconds : 5), token);
            }
        }
예제 #2
0
        private static void MeetTest()
        {
            if (!File.Exists("config.json"))
            {
                MeetBot.CreateEmpty <Config>();
                Console.WriteLine("Created sample config.");
                return;
            }
            Config  config = JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.GetFullPath(".") + "/config.json"));
            MeetBot bot    = new MeetBot(config);

            try
            {
                bool loggedIn = bot.Login();
                if (!loggedIn)
                {
                    Console.WriteLine("Retrying login");
                    for (int i = 0; i < 3 && !loggedIn; i++)
                    {
                        loggedIn = bot.Login();
                    }
                    Console.WriteLine("Logged in: " + loggedIn);
                }
                bot.EnterMeetOverview("https://meet.google.com/rje-zpyi-jcg");
                Console.WriteLine(bot.PeopleInMeetOverview());
                bot.EnterMeet();
                Task wait = WaitFor(10);
                while (!wait.IsCompleted)
                {
                    Console.WriteLine(bot.PeopleInMeet());
                }
                bot.LeaveMeet();
            }
            finally
            {
                bot.Dispose();
            }
        }