source: binary-improvements2/MapRendering/Web/API/GetPlayerInventories.cs@ 382

Last change on this file since 382 was 382, checked in by alloc, 2 years ago

Switched to use SpaceWizards.HttpListener

File size: 1.0 KB
Line 
1using System.Collections.Generic;
2using System.Net;
3using AllocsFixes.JSON;
4using AllocsFixes.PersistentData;
5using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
6using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
7
8namespace AllocsFixes.NetConnections.Servers.Web.API {
9 public class GetPlayerInventories : WebAPI {
10 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
11 int _permissionLevel) {
12 GetPlayerInventory.GetInventoryArguments (_req, out bool showIconColor, out bool showIconName);
13
14 JSONArray AllInventoriesResult = new JSONArray ();
15
16 foreach (KeyValuePair<PlatformUserIdentifierAbs, Player> kvp in PersistentContainer.Instance.Players.Dict) {
17 Player p = kvp.Value;
18
19 if (p == null) {
20 continue;
21 }
22
23 if (p.IsOnline) {
24 AllInventoriesResult.Add (GetPlayerInventory.DoPlayer (kvp.Key.CombinedString, p, showIconColor, showIconName));
25 }
26 }
27
28 WriteJSON (_resp, AllInventoriesResult);
29 }
30 }
31}
Note: See TracBrowser for help on using the repository browser.