[251] | 1 | using AllocsFixes.JSON;
|
---|
| 2 | using AllocsFixes.LiveData;
|
---|
| 3 | using AllocsFixes.PersistentData;
|
---|
| 4 | using System;
|
---|
| 5 | using System.Collections.Generic;
|
---|
| 6 | using System.Net;
|
---|
| 7 |
|
---|
| 8 | namespace AllocsFixes.NetConnections.Servers.Web.API
|
---|
| 9 | {
|
---|
| 10 | public class GetStats : WebAPI
|
---|
| 11 | {
|
---|
| 12 | public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel)
|
---|
| 13 | {
|
---|
| 14 | JSONObject result = new JSONObject ();
|
---|
| 15 |
|
---|
| 16 | JSONObject time = new JSONObject ();
|
---|
| 17 | time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
|
---|
| 18 | time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
|
---|
| 19 | time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
|
---|
| 20 | result.Add ("gametime", time);
|
---|
| 21 |
|
---|
| 22 | result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
|
---|
| 23 | result.Add ("hostiles", new JSONNumber (Hostiles.Count));
|
---|
| 24 | result.Add ("animals", new JSONNumber (Animals.Count));
|
---|
| 25 |
|
---|
| 26 | WriteJSON (resp, result);
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 |
|
---|