Last change
on this file since 390 was 387, checked in by alloc, 2 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
|
Rev | Line | |
---|
[251] | 1 | using AllocsFixes.JSON;
|
---|
| 2 | using AllocsFixes.LiveData;
|
---|
| 3 |
|
---|
[325] | 4 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
[387] | 5 | public class GetWebUIUpdates : AbsWebAPI {
|
---|
| 6 | public override void HandleRequest (RequestContext _context) {
|
---|
[251] | 7 | int latestLine;
|
---|
[387] | 8 | if (_context.Request.QueryString ["latestLine"] == null ||
|
---|
| 9 | !int.TryParse (_context.Request.QueryString ["latestLine"], out latestLine)) {
|
---|
[251] | 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));
|
---|
[313] | 22 | result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
|
---|
| 23 | result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
|
---|
[251] | 24 |
|
---|
| 25 | result.Add ("newlogs", new JSONNumber (LogBuffer.Instance.LatestLine - latestLine));
|
---|
| 26 |
|
---|
[387] | 27 | WebUtils.WriteJson (_context.Response, result);
|
---|
[251] | 28 | }
|
---|
[279] | 29 |
|
---|
| 30 | public override int DefaultPermissionLevel () {
|
---|
| 31 | return 2000;
|
---|
| 32 | }
|
---|
[251] | 33 | }
|
---|
[325] | 34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.