コード例 #1
0
ファイル: NetworkQueue.cs プロジェクト: Tsarpf/Mobile-MMO
 public static void Write(JSONEvent json)
 {
     lock (queue)
     {
         queue.Enqueue(json);
     }
 }
コード例 #2
0
        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));
        }
コード例 #3
0
    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);
        }
    }
コード例 #4
0
        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));
        }
コード例 #5
0
 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();
 }