source: binary-improvements/MapRendering/Web/API/GetWebUIUpdates.cs@ 250

Last change on this file since 250 was 250, checked in by alloc, 9 years ago

Fixes 5_7_9

File size: 1.1 KB
Line 
1using AllocsFixes.JSON;
2using AllocsFixes.PersistentData;
3using System;
4using System.Collections.Generic;
5using System.Net;
6
7namespace AllocsFixes.NetConnections.Servers.Web.API
8{
9 public class GetWebUIUpdates : WebAPI {
10 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) {
11 int latestLine;
12 if (req.QueryString ["latestLine"] == null || !int.TryParse (req.QueryString ["latestLine"], out latestLine)) {
13 latestLine = 0;
14 }
15
16 JSONObject result = new JSONObject ();
17
18 JSONObject time = new JSONObject ();
19 time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
20 time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
21 time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
22 result.Add ("gametime", time);
23
24 result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
25
26 result.Add ("newlogs", new JSONNumber (LogBuffer.Instance.LatestLine - latestLine));
27
28 WriteJSON (resp, result);
29 }
30 }
31}
32
Note: See TracBrowser for help on using the repository browser.