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