private void LoadNetworkFromJSON(string json) { if (json != null && json != "") { tree = JsonConvert.DeserializeObject <NetworkElement>(json); } }
public NetworkUtil() { HttpBaseProtocolFilter RootFilter = new HttpBaseProtocolFilter(); RootFilter.CacheControl.ReadBehavior = HttpCacheReadBehavior.NoCache; RootFilter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache; client = new HttpClient(RootFilter); tree = null; }
public static string ConvertTableToJSON() { NetworkElement tree = new NetworkElement(); //filter out camera publisher as it is heckin big for (int i = 0; i < tree.Children.Count; i++) { if (tree.Children.ElementAt(i).Key == "CameraPublisher") { tree.Children.RemoveAt(i); } } string myJson = JsonConvert.SerializeObject(tree); return(myJson); }
public object GetKey(string inputKey) { if (tree != null) { string[] tokens = inputKey.Split('/'); NetworkElement myElement = tree; int x = 0; while (myElement.Key != tokens.Last()) { var matches = myElement.Children.Where(ntItem => ntItem.Key == tokens[x]); try { if (matches.Count() > 0 && matches.First() != null) { myElement = matches.First(); } else { throw new Exception($"Key {tokens[x]} Not Found!"); } } catch (Exception e) { Console.WriteLine(e.Message); } x++; } return(myElement.Value); } else { return(null); } }
public static object GetKey(string inputKey, NetworkElement tree) { string[] tokens = inputKey.Split('/'); NetworkElement myElement = tree; int x = 0; while (myElement.Key != tokens.Last()) { var matches = myElement.Children.Where(ntItem => ntItem.Key == tokens[x]); if (matches.Count() > 0 && matches.First() != null) { myElement = matches.First(); } else { throw new Exception($"Key {tokens[x]} Not Found!"); } x++; } return(myElement.Value); }
public IEnumerator UpdateNtTable() { UnityWebRequest www = UnityWebRequest.Get("http://infinitepc:4089/GetNetworkTablesJSON/"); yield return(www.Send()); if (www.isError) { Debug.Log(www.error); } else { // Show results as text //Debug.Log(www.downloadHandler.text); string json = www.downloadHandler.text; if (json != null && json != "") { tree = JsonConvert.DeserializeObject <NetworkElement>(json); } OnRaiseNetworkUpdatedEvent(new NetworkUpdatedEvent(tree)); } }
public NetworkUtil() { tree = null; }
public NetworkUpdatedEvent(NetworkElement tree) { this.tree = tree; }