Exemplo n.º 1
0
        private async Task CheckServer(ServerModel server)
        {
            // Get our status for this server
            if (!_serverCheckStatuses.ContainsKey(server.ServerId))
            {
                _serverCheckStatuses[server.ServerId] = new ServerCheckStatus();
            }
            var checkStatus = _serverCheckStatuses[server.ServerId];
            int delaysec    = (server.UpStatus == ServerModel.ServerUpStatusEnum.Up ? server.StatusOnlineIntervalSeconds : server.StatusOfflineIntervalSeconds);

            // Is it time to check again
            if (DateTime.UtcNow - checkStatus.LastCheckedUtc < TimeSpan.FromSeconds(delaysec))
            {
                return;
            }
            checkStatus.LastCheckedUtc = DateTime.UtcNow;
            var address = AddressParser.Parse(server.ServerIpAndPort);

            if (string.IsNullOrEmpty(address.Ip) || address.Port <= 0)
            {
                return;
            }
            bool up = await IsUdpServerUp(address.Ip, address.Port);

            string status = GetStatusString(up);

            server.UpStatus = (up ? ServerModel.ServerUpStatusEnum.Up : ServerModel.ServerUpStatusEnum.Down);
            if (server.ConnectionStatus != status)
            {
                CallToUpdate(server, status);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called on UI thread
 /// </summary>
 private void PerformUpdate(ServerModel server, string status)
 {
     if (server.ConnectionStatus != status)
     {
         server.ConnectionStatus = status;
     }
 }
Exemplo n.º 3
0
 public Server(UserAccount acct, ServerModel serverItem)
 {
     _myAccount = acct;
     _myServer  = serverItem;
     _myServer.PropertyChanged += ServerItemPropertyChanged;
     AvailableCharacters        = new ObservableCollection <AccountCharacter>();
     ServerStatusSymbol         = "";
 }
Exemplo n.º 4
0
        private void Import(object parameter)
        {
            ServerModel server = parameter as ServerModel;

            if (IsModelInOurServers(server))
            {
                return;
            }
            ServerManager.ServerList.Add(server);
            LoadServers();
        }
Exemplo n.º 5
0
 private void CallToUpdate(ServerModel server, string status)
 {
     if (System.Windows.Application.Current == null)
     {
         return;
     }
     System.Windows.Application.Current.Dispatcher.BeginInvoke(
         DispatcherPriority.Normal, new Action(() =>
     {
         PerformUpdate(server, status);
     }));
 }
Exemplo n.º 6
0
        private void LoadServers()
        {
            _serverModels.Clear();
            var persister = new GameManagement.ServerPersister(ServerManager.GetServerDataFolder());

            var allServers       = persister.GetWildWestServerList();
            var availableServers = allServers.Where(q => !IsInOurServers(q));

            foreach (var servdata in availableServers)
            {
                ServerModel model = ServerModel.Create(servdata);
                _serverModels.Add(model);
            }
        }
Exemplo n.º 7
0
        private static void AddOrUpdateServer(GameManagement.ServerPersister.ServerData servdata)
        {
            var existing = ServerList.FirstOrDefault(s => s.IsEqual(servdata));

            if (existing != null)
            {
                existing.ServerName        = servdata.ServerName;
                existing.ServerDescription = servdata.ServerDesc;
                existing.ServerIpAndPort   = servdata.ConnectionString;
                existing.RodatSetting      = servdata.RodatSetting;
                existing.VisibilitySetting = servdata.VisibilitySetting;
                existing.EMU = servdata.EMU;
            }
            else
            {
                ServerModel model = ServerModel.Create(servdata);
                ServerList.Add(model);
            }
        }
Exemplo n.º 8
0
        public override bool Equals(object obj)
        {
            ServerModel ob2 = (obj as ServerModel);

            if (ob2 == null)
            {
                return(false);
            }
            if (this.ServerId == ob2.ServerId)
            {
                return(true);
            }

            /*
             * We are now using exact id match, not equivalent data
             * if (GetHashCode() != ob2.GetHashCode()) { return false; }
             * if (ServerName != ob2.ServerName) { return false; }
             * if (ServerIpAndPort != ob2.ServerIpAndPort) { return false; }
             * */
            return(false);
        }
        private void LaunchSimpleGame(string path, ServerModel server, string account, string pwd)
        {
            SaveToSettings();
            var launchItem = new LaunchItem();

            launchItem.CustomLaunchPath = path;
            launchItem.ServerName       = server.ServerName;
            launchItem.AccountName      = account;
            launchItem.Password         = pwd;
            launchItem.IpAndPort        = server.ServerIpAndPort;
            launchItem.EMU = server.EMU;
            launchItem.CharacterSelected = null; // no character choices for SimpleLaunch, b/c that requires SteelFilter
            launchItem.RodatSetting      = server.RodatSetting;
            launchItem.SecureSetting     = server.SecureSetting;
            launchItem.IsSimpleLaunch    = true;

            if (LaunchingEvent == null)
            {
                throw new Exception("SimpleLaunchWindowViewModel.LaunchingEvent null");
            }
            LaunchingEvent(launchItem);
        }
Exemplo n.º 10
0
        internal static ServerModel Create(SteelBotLauncher.GameManagement.ServerPersister.ServerData data)
        {
            ServerModel server = new ServerModel();

            server.ServerId          = data.ServerId;
            server.ServerName        = data.ServerName;
            server.ServerAlias       = data.ServerAlias;
            server.ServerDescription = data.ServerDesc;
            server.ServerIpAndPort   = data.ConnectionString;
            server.GameApiUrl        = data.GameApiUrl;
            server.LoginServerUrl    = data.LoginServerUrl;
            server.DiscordUrl        = data.DiscordUrl;
            server.EMU                          = data.EMU;
            server.RodatSetting                 = data.RodatSetting;
            server.SecureSetting                = data.SecureSetting;
            server.VisibilitySetting            = data.VisibilitySetting;
            server.ServerSource                 = data.ServerSource;
            server.ConnectionStatus             = "?";
            server.ConnectionColor              = System.Windows.Media.Brushes.AntiqueWhite;
            server.UpStatus                     = ServerUpStatusEnum.Unknown;
            server.StatusOfflineIntervalSeconds = 15;
            server.StatusOnlineIntervalSeconds  = 300;
            return(server);
        }
Exemplo n.º 11
0
 public SimpleServerItem(ServerModel server)
 {
     _item = server;
     _item.PropertyChanged += OnItemPropertyChanged;
 }
Exemplo n.º 12
0
 private bool IsModelInOurServers(ServerModel server)
 {
     return(ServerManager.ServerList.Contains(server));
 }