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); }
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); }
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); }
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); }
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); }
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); }
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); }