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;
                }
            }
        }
 private bool IsCurrentServer(ServerStatus thisServer, IDataContext context)
 {
     return thisServer.Id == context.Session.CurrentServer.Id;
 }
示例#3
0
 public SeederAction(SeederActionType actionType, string actionReason, ServerStatus serverStatus = null)
 {
     ActionType = actionType;
     ActionReason = actionReason;
     ServerStatus = serverStatus;
 }
示例#4
0
 public SeederAction(SeederActionType actionType, string actionReason, ServerStatus serverStatus = null)
 {
     ActionType   = actionType;
     ActionReason = actionReason;
     ServerStatus = serverStatus;
 }