Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 | using AllocsFixes.PersistentData;
|
---|
3 | using System;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using System.Net;
|
---|
6 |
|
---|
7 | namespace 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.