public static void Write(JSONEvent json) { lock (queue) { queue.Enqueue(json); } }
public static string SerializeBlob(BlobEventModel blob) { Value blobsValue = new Value { Centroid = blob.Centroid, Area = blob.Area }; JSONEvent jsonEvent = new JSONEvent { Id = blob.Id, Event = blob.Event, Ts = blob.Timestamp, Value = blobsValue }; return(Serialize(jsonEvent)); }
private IEnumerator StartParsingCourotine(string jsonName, EJSONType jsonType, UnityAction <string> unityAction) { if (!File.Exists(CONST_VAR.JSON_PATH + jsonName)) //json notFound { JSONCreated(jsonName); } else { _URLLink = new WWW(CONST_VAR.JSON_URL + jsonName); yield return(_URLLink); JSONNode node = JSON.Parse(_URLLink.text); Debug.Log(node); _JSONEventCaller = new JSONEvent(); _JSONEventCaller.AddListener(unityAction); } }
public static string SerializeBodies(BodyEventModel bodyEvent) { Value jsonValue = new Value { Bodies = new List <JSONBody>() }; foreach (var body in bodyEvent.Bodies) { JSONBody jsonBody = new JSONBody { ID = body.TrackingId.ToString(), Joints = new List <JSONJoint>() }; foreach (var bodyJoint in body.Joints) { Joint joint = bodyJoint.Value; jsonBody.Joints.Add(new JSONJoint { Name = joint.JointType.ToString().ToLower(), X = joint.Position.X, Y = joint.Position.Y, Z = joint.Position.Z }); } jsonValue.Bodies.Add(jsonBody); } JSONEvent jsonEvent = new JSONEvent { Id = bodyEvent.Id, Event = bodyEvent.Event, Ts = bodyEvent.Timestamp, Value = jsonValue }; return(Serialize(jsonEvent)); }
static void WriteJSONMessage(SslStream sslStream, JSONEvent eventObj) { string message = JsonConvert.SerializeObject(eventObj); //Console.WriteLine(message); byte[] msg = Encoding.UTF8.GetBytes(message); sslStream.Write(msg); sslStream.Flush(); }