- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetAnimalsLocation.cs
r313 r325 1 using AllocsFixes.JSON; 1 using System.Collections.Generic; 2 using System.Net; 3 using AllocsFixes.JSON; 2 4 using AllocsFixes.LiveData; 3 using System;4 using System.Collections.Generic;5 using System.Net;6 5 7 namespace AllocsFixes.NetConnections.Servers.Web.API 8 { 9 class GetAnimalsLocation : WebAPI 10 { 11 private List<EntityAnimal> animals = new List<EntityAnimal> (); 6 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 internal class GetAnimalsLocation : WebAPI { 8 private readonly List<EntityAnimal> animals = new List<EntityAnimal> (); 12 9 13 public override void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 14 15 JSONArray animalsJsResult = new JSONArray();10 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, 11 int permissionLevel) { 12 JSONArray animalsJsResult = new JSONArray (); 16 13 17 14 Animals.Instance.Get (animals); 18 for (int i = 0; i < animals.Count; i++) 19 { 15 for (int i = 0; i < animals.Count; i++) { 20 16 EntityAnimal entity = animals [i]; 21 Vector3i position = new Vector3i(entity.GetPosition());17 Vector3i position = new Vector3i (entity.GetPosition ()); 22 18 23 JSONObject jsonPOS = new JSONObject();24 jsonPOS.Add("x", new JSONNumber(position.x));25 jsonPOS.Add("y", new JSONNumber(position.y));26 jsonPOS.Add("z", new JSONNumber(position.z));19 JSONObject jsonPOS = new JSONObject (); 20 jsonPOS.Add ("x", new JSONNumber (position.x)); 21 jsonPOS.Add ("y", new JSONNumber (position.y)); 22 jsonPOS.Add ("z", new JSONNumber (position.z)); 27 23 28 JSONObject pJson = new JSONObject();29 pJson.Add("id", new JSONNumber(entity.entityId));24 JSONObject pJson = new JSONObject (); 25 pJson.Add ("id", new JSONNumber (entity.entityId)); 30 26 31 if (!string.IsNullOrEmpty(entity.EntityName)) 32 pJson.Add("name", new JSONString(entity.EntityName)); 33 else 34 pJson.Add("name", new JSONString("animal class #" + entity.entityClass.ToString())); 27 if (!string.IsNullOrEmpty (entity.EntityName)) { 28 pJson.Add ("name", new JSONString (entity.EntityName)); 29 } else { 30 pJson.Add ("name", new JSONString ("animal class #" + entity.entityClass)); 31 } 35 32 36 pJson.Add("position", jsonPOS);33 pJson.Add ("position", jsonPOS); 37 34 38 animalsJsResult.Add(pJson);39 40 41 WriteJSON(resp, animalsJsResult);42 43 35 animalsJsResult.Add (pJson); 36 } 37 38 WriteJSON (resp, animalsJsResult); 39 } 40 } 44 41 }
Note:
See TracChangeset
for help on using the changeset viewer.