Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 | using AllocsFixes.LiveData;
|
---|
3 | using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
|
---|
4 | using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
|
---|
5 |
|
---|
6 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
7 | public class GetStats : WebAPI {
|
---|
8 | public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
|
---|
9 | int _permissionLevel) {
|
---|
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));
|
---|
19 | result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
|
---|
20 | result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
|
---|
21 |
|
---|
22 | WriteJSON (_resp, result);
|
---|
23 | }
|
---|
24 |
|
---|
25 | public override int DefaultPermissionLevel () {
|
---|
26 | return 2000;
|
---|
27 | }
|
---|
28 | }
|
---|
29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.