Last change
on this file since 454 was 454, checked in by alloc, 16 months ago |
24_29_43
Switched over to vanilla Web infrastructure
|
File size:
1.3 KB
|
Rev | Line | |
---|
[251] | 1 | using AllocsFixes.JSON;
|
---|
| 2 | using AllocsFixes.LiveData;
|
---|
[454] | 3 | using Webserver;
|
---|
| 4 | using Webserver.WebAPI;
|
---|
[251] | 5 |
|
---|
[454] | 6 | namespace AllocsFixes.WebAPIs {
|
---|
| 7 | public class GetWebUIUpdates : AbsWebAPI {
|
---|
| 8 | public override void HandleRequest (RequestContext _context) {
|
---|
[251] | 9 | int latestLine;
|
---|
[454] | 10 | if (_context.Request.QueryString ["latestLine"] == null ||
|
---|
| 11 | !int.TryParse (_context.Request.QueryString ["latestLine"], out latestLine)) {
|
---|
[251] | 12 | latestLine = 0;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | JSONObject result = new JSONObject ();
|
---|
| 16 |
|
---|
| 17 | JSONObject time = new JSONObject ();
|
---|
| 18 | time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
|
---|
| 19 | time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
|
---|
| 20 | time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
|
---|
| 21 | result.Add ("gametime", time);
|
---|
| 22 |
|
---|
| 23 | result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
|
---|
[313] | 24 | result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
|
---|
| 25 | result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
|
---|
[251] | 26 |
|
---|
| 27 | result.Add ("newlogs", new JSONNumber (LogBuffer.Instance.LatestLine - latestLine));
|
---|
| 28 |
|
---|
[454] | 29 | LegacyApiHelper.WriteJSON (_context.Response, result);
|
---|
[251] | 30 | }
|
---|
[279] | 31 |
|
---|
| 32 | public override int DefaultPermissionLevel () {
|
---|
| 33 | return 2000;
|
---|
| 34 | }
|
---|
[251] | 35 | }
|
---|
[325] | 36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.