Rev | Line | |
---|
[251] | 1 | using AllocsFixes.JSON;
|
---|
| 2 | using AllocsFixes.LiveData;
|
---|
[382] | 3 | using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
|
---|
| 4 | using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
|
---|
[251] | 5 |
|
---|
[325] | 6 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
| 7 | public class GetStats : WebAPI {
|
---|
[351] | 8 | public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
|
---|
| 9 | int _permissionLevel) {
|
---|
[251] | 10 | JSONObject result = new JSONObject ();
|
---|
| 11 |
|
---|
| 12 | JSONObject time = new JSONObject ();
|
---|
| 13 | time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
|
---|
| 14 | time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
|
---|
| 15 | time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
|
---|
| 16 | result.Add ("gametime", time);
|
---|
| 17 |
|
---|
| 18 | result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
|
---|
[313] | 19 | result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
|
---|
| 20 | result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
|
---|
[251] | 21 |
|
---|
[351] | 22 | WriteJSON (_resp, result);
|
---|
[251] | 23 | }
|
---|
[279] | 24 |
|
---|
| 25 | public override int DefaultPermissionLevel () {
|
---|
| 26 | return 2000;
|
---|
| 27 | }
|
---|
[251] | 28 | }
|
---|
[325] | 29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.