public void Update(bool supressRefresh = false)
 {
     try
     {
         IsUpdating = true;
         var serverResult = _queryClient.Execute();
         Execute.OnUiThread(() =>
         {
             App.Events.Publish(new PlayersChangedEvent(Players, serverResult.Players));
             Players       = new ObservableCollection <Player>(serverResult.Players.OrderBy(x => x.Name));
             LastException = null;
             Settings      = serverResult.Settings;
             Ping          = serverResult.Ping;
             App.Events.Publish(new ServerUpdated(this, supressRefresh));
         });
     }
     catch (Exception ex)
     {
         Execute.OnUiThread(() =>
         {
             LastException = ex.Message;
             PropertyHasChanged("Name", "Ping");
             App.Events.Publish(new ServerUpdated(this, supressRefresh));
         });
     }
     finally
     {
         IsUpdating = false;
     }
 }
Beispiel #2
0
        public void Update(bool supressRefresh = false)
        {
            try
            {
                IsUpdating = true;
                ServerQueryResult serverResult = _queryClient.Execute();
                Execute.OnUiThread(() =>
                {
                    JoinAddress   = serverResult.IP;
                    JoinPort      = serverResult.Port;
                    Players       = new ObservableCollection <Player>(serverResult.Players.OrderBy(x => x.Name));
                    LastException = null;

                    //Ugly hack to go around 63 char limit, remove when fixed
                    if (Settings.ContainsKey("hostname"))
                    {
                        string oldHostname = Settings["hostname"];
                        string newHostname = serverResult.Settings["hostname"];

                        if (newHostname.Length == (64 - 1))                       //it probably got cut off
                        {
                            if (newHostname.Length < oldHostname.Length)
                            {
                                serverResult.Settings["hostname"] = newHostname + oldHostname.Substring(newHostname.Length);
                            }
                        }
                    }

                    Settings = serverResult.Settings;
                    Ping     = serverResult.Ping;
                    App.Events.Publish(new ServerUpdated(this, supressRefresh));
                });
            }
            catch (Exception ex)
            {
                Execute.OnUiThread(() =>
                {
                    LastException = ex.Message;
                    PropertyHasChanged("Name", "Ping");
                    App.Events.Publish(new ServerUpdated(this, supressRefresh));
                });
            }
            finally
            {
                IsUpdating = false;
            }
        }