private async Task FindQuestIPs() { Progress <List <IPAddress> > progress = new Progress <List <IPAddress> >(ips => { QuestIPsBox.Text = string.Join('\n', ips.Select(ip => ip.ToString())); LoadingLabel.Content = "Scanning Network..."; }); List <IPAddress> ips = await QuestIPFetching.FindAllQuestIPs(progress); LoadingLabel.Content = "Fetching EchoVR API for each Quest..."; List <(IPAddress, string)> responses = await QuestIPFetching.PingEchoVRAPIAsync(ips); List <(IPAddress, Frame)> frames = responses.Select(r => r.Item2 != null && !r.Item2.StartsWith("<html>") ? (r.Item1, JsonConvert.DeserializeObject <Frame>(r.Item2)) : (r.Item1, null)).ToList(); string output = string.Join('\n', frames.Select(ip => { (IPAddress ipAddress, Frame f) = ip; string status = f != null ? f.err_code == -6 ? "Lobby" : Program.CurrentSparkLink(f?.sessionid) + "\t" + f?.game_status + "\t" + "Players: " + f?.GetAllPlayers().Count: ""; return(ipAddress + "\t" + f?.client_name + " \t" + status); })); QuestIPsBox.Text = output; LoadingLabel.Content = ""; }
private async void QuestClicked(object sender, RoutedEventArgs e) { setupLabel.Content = Properties.Resources.Searching_for_Quest_on_network; setupText.Visibility = Visibility.Hidden; spectatorButton.IsEnabled = false; playerButton.IsEnabled = false; Progress <string> progress = new Progress <string>(s => setupLabel.Content = s); await Task.Factory.StartNew(() => Program.echoVRIP = QuestIPFetching.FindQuestIP(progress), TaskCreationOptions.None); spectatorButton.IsEnabled = true; playerButton.IsEnabled = true; SparkSettings.instance.echoVRIP = Program.echoVRIP; SparkSettings.instance.Save(); Thread.Sleep(2000); Close(); }