|
Last change
on this file since 390 was 387, checked in by alloc, 3 years ago |
|
Big refactoring in Web to pass around a Context instead of a bunch of individual arguments all the time
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | using AllocsFixes.JSON;
|
|---|
| 2 | using AllocsFixes.LiveData;
|
|---|
| 3 |
|
|---|
| 4 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
|---|
| 5 | public class GetWebUIUpdates : AbsWebAPI {
|
|---|
| 6 | public override void HandleRequest (RequestContext _context) {
|
|---|
| 7 | int latestLine;
|
|---|
| 8 | if (_context.Request.QueryString ["latestLine"] == null ||
|
|---|
| 9 | !int.TryParse (_context.Request.QueryString ["latestLine"], out latestLine)) {
|
|---|
| 10 | latestLine = 0;
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | JSONObject result = new JSONObject ();
|
|---|
| 14 |
|
|---|
| 15 | JSONObject time = new JSONObject ();
|
|---|
| 16 | time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
|
|---|
| 17 | time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
|
|---|
| 18 | time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
|
|---|
| 19 | result.Add ("gametime", time);
|
|---|
| 20 |
|
|---|
| 21 | result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
|
|---|
| 22 | result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
|
|---|
| 23 | result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
|
|---|
| 24 |
|
|---|
| 25 | result.Add ("newlogs", new JSONNumber (LogBuffer.Instance.LatestLine - latestLine));
|
|---|
| 26 |
|
|---|
| 27 | WebUtils.WriteJson (_context.Response, result);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | public override int DefaultPermissionLevel () {
|
|---|
| 31 | return 2000;
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.