Last change
on this file was 455, checked in by alloc, 16 months ago |
25_30_44
- Got rid (mostly) of custom JSON serialization
- Some code cleanup
|
File size:
1012 bytes
|
Line | |
---|
1 | using System.Collections.Generic;
|
---|
2 | using AllocsFixes.PersistentData;
|
---|
3 | using JetBrains.Annotations;
|
---|
4 | using Utf8Json;
|
---|
5 | using Webserver;
|
---|
6 | using Webserver.WebAPI;
|
---|
7 |
|
---|
8 | namespace AllocsFixes.WebAPIs {
|
---|
9 | [UsedImplicitly]
|
---|
10 | public class GetPlayerInventories : AbsWebAPI {
|
---|
11 | public override void HandleRequest (RequestContext _context) {
|
---|
12 | GetPlayerInventory.GetInventoryArguments (_context, out bool showIconColor, out bool showIconName);
|
---|
13 |
|
---|
14 | JsonWriter writer = new JsonWriter ();
|
---|
15 |
|
---|
16 | writer.WriteBeginArray ();
|
---|
17 |
|
---|
18 | bool first = true;
|
---|
19 |
|
---|
20 | foreach (KeyValuePair<PlatformUserIdentifierAbs, Player> kvp in PersistentContainer.Instance.Players.Dict) {
|
---|
21 | Player p = kvp.Value;
|
---|
22 |
|
---|
23 | if (p == null) {
|
---|
24 | continue;
|
---|
25 | }
|
---|
26 |
|
---|
27 | if (p.IsOnline) {
|
---|
28 | if (!first) {
|
---|
29 | writer.WriteValueSeparator ();
|
---|
30 | }
|
---|
31 |
|
---|
32 | first = false;
|
---|
33 |
|
---|
34 | GetPlayerInventory.DoPlayer (ref writer, p, showIconColor, showIconName);
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | writer.WriteEndArray ();
|
---|
39 |
|
---|
40 | WebUtils.WriteJsonData (_context.Response, ref writer);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.