From 3307f57f3601e3e77b0923dd0b3ff1c49b65020e Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Wed, 16 Sep 2020 13:48:31 +0200 Subject: [PATCH] added getting all users from response --- RH-Engine/JSONParser.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/RH-Engine/JSONParser.cs b/RH-Engine/JSONParser.cs index d42adb6..bda371c 100644 --- a/RH-Engine/JSONParser.cs +++ b/RH-Engine/JSONParser.cs @@ -10,20 +10,23 @@ namespace RH_Engine class JSONParser { /// - /// parses the given response from the server into strings + /// returns all the users from the given response /// /// the message gotten from the server, without the length prefix /// - public static string[] Parse(string msg) + public static PC[] GetUsers(string msg) { dynamic jsonData = JsonConvert.DeserializeObject(msg); Newtonsoft.Json.Linq.JArray data = jsonData.data; + PC[] res = new PC[data.Count]; + int counter = 0; foreach (dynamic d in data) { - Console.WriteLine(d.clientinfo.host); + res[counter] = new PC(d.clientinfo.host, d.clientinfo.user); + counter++; } - return null; + return res; }