1 | using System;
|
---|
2 | using AllocsFixes.JSON;
|
---|
3 |
|
---|
4 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
5 | public class GetServerInfo : AbsWebAPI {
|
---|
6 | public override void HandleRequest (RequestContext _context) {
|
---|
7 | JSONObject serverInfo = new JSONObject ();
|
---|
8 |
|
---|
9 | GameServerInfo gsi = ConnectionManager.Instance.LocalServerInfo;
|
---|
10 |
|
---|
11 | foreach (string stringGamePref in Enum.GetNames (typeof (GameInfoString))) {
|
---|
12 | string value = gsi.GetValue ((GameInfoString) Enum.Parse (typeof (GameInfoString), stringGamePref));
|
---|
13 |
|
---|
14 | JSONObject singleStat = new JSONObject ();
|
---|
15 | singleStat.Add ("type", new JSONString ("string"));
|
---|
16 | singleStat.Add ("value", new JSONString (value));
|
---|
17 |
|
---|
18 | serverInfo.Add (stringGamePref, singleStat);
|
---|
19 | }
|
---|
20 |
|
---|
21 | foreach (string intGamePref in Enum.GetNames (typeof (GameInfoInt))) {
|
---|
22 | int value = gsi.GetValue ((GameInfoInt) Enum.Parse (typeof (GameInfoInt), intGamePref));
|
---|
23 |
|
---|
24 | JSONObject singleStat = new JSONObject ();
|
---|
25 | singleStat.Add ("type", new JSONString ("int"));
|
---|
26 | singleStat.Add ("value", new JSONNumber (value));
|
---|
27 |
|
---|
28 | serverInfo.Add (intGamePref, singleStat);
|
---|
29 | }
|
---|
30 |
|
---|
31 | foreach (string boolGamePref in Enum.GetNames (typeof (GameInfoBool))) {
|
---|
32 | bool value = gsi.GetValue ((GameInfoBool) Enum.Parse (typeof (GameInfoBool), boolGamePref));
|
---|
33 |
|
---|
34 | JSONObject singleStat = new JSONObject ();
|
---|
35 | singleStat.Add ("type", new JSONString ("bool"));
|
---|
36 | singleStat.Add ("value", new JSONBoolean (value));
|
---|
37 |
|
---|
38 | serverInfo.Add (boolGamePref, singleStat);
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | WebUtils.WriteJson (_context.Response, serverInfo);
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|