Exemplo n.º 1
0
    // Token: 0x06001AF6 RID: 6902 RVA: 0x0008BD84 File Offset: 0x00089F84
    public static ServerLoadRequest Run(PhotonServer server, Action callback)
    {
        ServerLoadRequest serverLoadRequest = new ServerLoadRequest(server, callback);

        serverLoadRequest.Run();
        return(serverLoadRequest);
    }
        public async Task <IHttpActionResult> Post([FromBody] ServerLoadRequest request)
        {
            this.serverLoadDataValidator = new ServerLoadDataValidator(request);
            if (!this.serverLoadDataValidator.IsValid())
            {
                return(BadRequest("Unable to store data due to invalid properties"));
            }

            // normally would use AutoMapper here but doing it manually to keep it simple
            ServerLoadTransaction transaction = new ServerLoadTransaction
            {
                TimeStamp  = DateTime.Now,
                ServerName = request.ServerName,
                CpuLoad    = request.CpuLoad,
                RamLoad    = request.RamLoad
            };

            try
            {
                await this.ServerLoadService.Record(transaction);

                return(Ok()); // hack: this should really be Created but we don't have a route in this implementation
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 3
0
        public void ServerLoadData_Validator_CpuLoadNegative_Fail()
        {
            var data = new ServerLoadRequest
            {
                ServerName = "MyServer",
                RamLoad    = 11.009,
                CpuLoad    = -13.23
            };

            var validator = new ServerLoadDataValidator(data);

            Assert.IsFalse(validator.IsValid());
        }
Exemplo n.º 4
0
        public void ServerLoadData_Validator_ServerNameEmpty_Fail()
        {
            var data = new ServerLoadRequest
            {
                ServerName = string.Empty,
                RamLoad    = 11.009,
                CpuLoad    = 9.034
            };

            var validator = new ServerLoadDataValidator(data);

            Assert.IsFalse(validator.IsValid());
        }
Exemplo n.º 5
0
        public void ServerLoadData_Validator_CpuLoadZero_Success()
        {
            var data = new ServerLoadRequest
            {
                ServerName = "MyServer",
                RamLoad    = 11.009,
                CpuLoad    = 0.0
            };

            var validator = new ServerLoadDataValidator(data);

            Assert.IsTrue(validator.IsValid());
        }
Exemplo n.º 6
0
 // Token: 0x06001333 RID: 4915 RVA: 0x000705D4 File Offset: 0x0006E7D4
 public IEnumerator StartUpdatingServerLoads()
 {
     foreach (PhotonServer server in this._gameServers.Values)
     {
         ServerLoadRequest request;
         if (!this._loadRequests.TryGetValue(server.Id, out request))
         {
             request = ServerLoadRequest.Run(server, delegate()
             {
                 this.UpdateGamesAndPlayerCount();
             });
             this._loadRequests.Add(server.Id, request);
         }
         if (request.RequestState != ServerLoadRequest.RequestStateType.Waiting)
         {
             request.Run();
         }
         yield return(new WaitForSeconds(0.1f));
     }
     yield break;
 }
 public ServerLoadDataValidator(ServerLoadRequest data)
 {
     this.data = data;
 }