Esempio n. 1
0
        private async Task UpdateServerStatus(ServerStatus serverStatus)
        {
            if (String.IsNullOrEmpty(serverStatus.Id))
                return;

            using (var httpClient = new HttpClient())
            {
                var address = String.Format(Constants.BattlelogUrlTemplates.ServerStatus, serverStatus.Id);
                var response = await httpClient.GetStringAsync(address).ConfigureAwait(true);

                if (String.IsNullOrEmpty(response))
                    return;

                
                ServerInfo serverInfo;

                try
                {
                    serverInfo = JsonConvert.DeserializeObject<ServerInfo>(response);
                }
                catch
                {
                    return;
                }

                if (serverInfo != null && serverInfo.Slots != null && serverInfo.Slots.Players != null)
                {
                    serverStatus.CurPlayers = serverInfo.Slots.Players.Current;
                    serverStatus.ServerMax = serverInfo.Slots.Players.Max;
                }
            }
        }
Esempio n. 2
0
 private bool IsCurrentServer(ServerStatus thisServer, IDataContext context)
 {
     return thisServer.Id == context.Session.CurrentServer.Id;
 }
Esempio n. 3
0
 public SeederAction(SeederActionType actionType, string actionReason, ServerStatus serverStatus = null)
 {
     ActionType = actionType;
     ActionReason = actionReason;
     ServerStatus = serverStatus;
 }
Esempio n. 4
0
 public SeederAction(SeederActionType actionType, string actionReason, ServerStatus serverStatus = null)
 {
     ActionType   = actionType;
     ActionReason = actionReason;
     ServerStatus = serverStatus;
 }