예제 #1
0
        public void PutServerInfo(HttpListenerContext context)
        {
            var inpStream = new StreamReader(context.Request.InputStream);

            EndpointInfo.ServerInfo serverInfo =
                JsonConvert.DeserializeObject <EndpointInfo.ServerInfo>(inpStream.ReadToEnd());
            string endPoint = ReqExtracters.ExtractEndpoint(context.Request);

            _db.PutServerInfo(new EndpointInfo(endPoint, serverInfo));

            this.SendResponse(context.Response, "", HttpStatusCode.OK);
        }
예제 #2
0
        public void PutServerMatch(HttpListenerContext context)
        {
            var inpStream = new StreamReader(context.Request.InputStream);

            string   endpoint  = ReqExtracters.ExtractEndpoint(context.Request);
            DateTime timestamp = ReqExtracters.ExtractTimestamp(context.Request);

            MatchInfo matchInfo =
                JsonConvert.DeserializeObject <MatchInfo>(inpStream.ReadToEnd());

            this.SendResponse(context.Response, "",
                              _db.PutServerMatch(endpoint, timestamp, matchInfo) ? HttpStatusCode.OK : HttpStatusCode.BadRequest);
        }
예제 #3
0
        public void GetServerInfo(HttpListenerContext context)
        {
            string endpoint = ReqExtracters.ExtractEndpoint(context.Request);

            EndpointInfo.ServerInfo serverInfo = _db.GetServerInfo(endpoint);

            if (serverInfo == null)
            {
                this.SendResponse(context.Response, "", HttpStatusCode.NotFound);
                return;
            }

            string serverInfoJson = JsonConvert.SerializeObject(serverInfo);

            this.SendResponse(context.Response, serverInfoJson, HttpStatusCode.OK);
        }
예제 #4
0
        public void GetServerMatch(HttpListenerContext context)
        {
            string   endpoint  = ReqExtracters.ExtractEndpoint(context.Request);
            DateTime timestamp = ReqExtracters.ExtractTimestamp(context.Request);

            MatchInfo matchInfo = _db.GetServerMatch(endpoint, timestamp);

            if (matchInfo == null)
            {
                this.SendResponse(context.Response, "", HttpStatusCode.NotFound);
                return;
            }

            string matchInfoJson = JsonConvert.SerializeObject(matchInfo);

            this.SendResponse(context.Response, matchInfoJson, HttpStatusCode.OK);
        }
예제 #5
0
        public void GetServerStats(HttpListenerContext context)
        {
            string stats = _enableCache ? _serverStatsCache[ReqExtracters.ExtractEndpoint(context.Request)] : _db.MakeServerStats(ReqExtracters.ExtractEndpoint(context.Request));

            this.SendResponse(context.Response, stats, HttpStatusCode.OK);
        }
예제 #6
0
        public void GetPopularServersReport(HttpListenerContext context)
        {
            string report = _enableCache ? _popularServersReportCache[ReqExtracters.ExtractCount(context.Request)] : _db.MakePopularServersReport(ReqExtracters.ExtractCount(context.Request));

            this.SendResponse(context.Response, report, HttpStatusCode.OK);
        }
예제 #7
0
        public void GetPlayerStats(HttpListenerContext context)
        {
            string stats = _enableCache ? _playerStatsCache[ReqExtracters.ExtractName(context.Request)] : _db.MakePlayerStats(ReqExtracters.ExtractName(context.Request));

            this.SendResponse(context.Response, stats, HttpStatusCode.OK);
        }