Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (trigger)
     {
         if (countPlant == int.Parse(IF.text))
         {
             trigger = false;
             CompleteSocketTime.text = Time.time.ToString();
             indicator.GetComponent <MeshRenderer>().material.color = Color.green;
             LatencyTest latencyTest = new LatencyTest(IF.text, startWaTime.text, CompleteWaTime.text, startSocketTime.text, CompleteSocketTime.text, "New Method");
             tCP.SocketSendByte(latencyTest);
         }
     }
 }
Esempio n. 2
0
 // Update is called once per frame
 void Update()
 {
     if (trigger)
     {
         if (srotc.totalSyncNum == int.Parse(IF.text))
         {
             trigger             = false;
             CompleteWaTime.text = Time.time.ToString();
             indicator.GetComponent <MeshRenderer>().material.color = Color.black;
             LatencyTest latencyTest = new LatencyTest(IF.text, startWaTime.text, CompleteWaTime.text, "NA", "NA", "Old Method");
             tCP.SocketSendByte(latencyTest);
         }
     }
 }
Esempio n. 3
0
    public void SendSingleDetails(int i)
    {
        pObject = new SingPlant
        {
            singName  = transform.parent.parent.name.Split('|')[0],
            singId    = int.Parse(transform.parent.parent.name.Split('|')[1]),
            param1    = transform.parent.GetChild(1).GetChild(0).GetComponent <InputField>().text,
            param2    = transform.parent.GetChild(2).GetChild(0).GetComponent <InputField>().text,
            param3    = transform.parent.GetChild(3).GetChild(0).GetComponent <InputField>().text,
            showPlant = i,
            header    = "pds"
        };
        //tCP.objClient = pObject;

        tCP = GameObject.Find("NetworkTransfer").GetComponent <TCPClientReceive>();
        tCP.SocketSendByte(pObject);

        //tCP.SendMessage(JsonUtility.ToJson(pObject));

        transform.parent.gameObject.SetActive(false);
    }
Esempio n. 4
0
    public void GeneratePlansetSend()
    {
        if (clientChoice == Client.PlantSet && name != "UIContainerAnchor")
        {
            pObject = new PlantSet
            {
                Name   = name,
                rotate = transform.localEulerAngles,
                pos    = transform.localPosition,
                header = "ps"
            };
            //tCP.objClient = pObject;

            tCP.SocketSendByte(pObject);

            //tCP.SendMessage(JsonUtility.ToJson(pObject));
        }
        else if (clientChoice == Client.SinglePlantDetails)
        {
            SendSingleDetails(1);
        }
    }
    public void PressAndGenerate()
    {
        if (Choice == Selection.CreateNew)
        {
            //TextAsset asset = Resources.Load("data_demonstration") as TextAsset;
            //anchorData = asset.bytes;
            //WorldAnchorTrans wat = new WorldAnchorTrans
            //{
            //    header = "wa",
            //    spaceName = spaceId,
            //    data = anchorData
            //};
            //tCP.SendWorlAnchor(wat);

            TimeCost tc4 = new TimeCost("OFALL", Time.time.ToString() + "start generating the anchor");
            tCP.SocketSendByte(tc4);
            //GameObject parentanchor = GameObject.Find("anchor1");
            WorldAnchor wa1 = anchorObject1.AddComponent <WorldAnchor>();
            WorldAnchorTransferBatch watb = new WorldAnchorTransferBatch();
            watb.AddWorldAnchor(anchorObject1.name, wa1);
            WorldAnchor wa2 = anchorObject2.AddComponent <WorldAnchor>();
            watb.AddWorldAnchor(anchorObject2.name, wa2);
            TimeCost tc5 = new TimeCost("OFALL", Time.time.ToString() + "Generating anchor done");
            tCP.SocketSendByte(tc5);
            imgSet.SetActive(true);
            //tCP.InitSocket();

            exportedData = new byte[0];
            e            = new List <byte>();
            indicator.GetComponent <MeshRenderer>().material.color = Color.yellow;
            syncOrNot = true;
            TimeCost tc6 = new TimeCost("OFALL", Time.time.ToString() + "start serializing the anchor");
            tCP.SocketSendByte(tc6);
            WorldAnchorTransferBatch.ExportAsync(watb,
                                                 (data) =>
            {
                e.AddRange(data);
                exportedData = data;
            },
                                                 (reason) =>
            {
                if (reason == SerializationCompletionReason.Succeeded)
                {
                    WorldAnchorTrans wat = new WorldAnchorTrans
                    {
                        header    = "wa",
                        spaceName = spaceId,
                        data      = e.ToArray()
                    };
                    TimeCost tc7 = new TimeCost("OFALL", Time.time.ToString() + "start sending anchor data");
                    tCP.SocketSendByte(tc7);
                    tCP.SendWorlAnchor(wat);
                    //CreateNewAnchorInManager();
                    indicator.GetComponent <MeshRenderer>().material.color = Color.green;

                    syncOrNot = true;
                }
                else
                {
                    Debug.Log("failed to upload world anchor, please try agagin");
                    indicator.GetComponent <MeshRenderer>().material.color = Color.red;
                }
            });
        }
        else if (Choice == Selection.SycnDirectly)
        {
            //tCP.InitSocket();
            StartCoroutine(DownloadAnchor(spaceId));
        }
        else if (Choice == Selection.LocationSync)
        {
            SendMsg msgNeed = new SendMsg("NeedToSyncPlantSet");
            tCP.SocketSendByte(msgNeed);
        }

        else if (Choice == Selection.CreateNew_multi)
        {
            WorldAnchor wa1 = anchorObject1.AddComponent <WorldAnchor>();
            WorldAnchorTransferBatch watb = new WorldAnchorTransferBatch();
            watb.AddWorldAnchor(anchorObject1.name, wa1);
            WorldAnchor wa2 = anchorObject2.AddComponent <WorldAnchor>();
            watb.AddWorldAnchor(anchorObject2.name, wa2);
            WorldAnchor wa3   = anchorObject3.AddComponent <WorldAnchor>();
            WorldAnchor wa4   = anchorObject4.AddComponent <WorldAnchor>();
            WorldAnchor wa5   = anchorObject5.AddComponent <WorldAnchor>();
            WorldAnchor wa2_1 = anchorObject2_1.AddComponent <WorldAnchor>();
            WorldAnchor wa3_1 = anchorObject3_1.AddComponent <WorldAnchor>();
            imgSet.SetActive(true);
        }
        else if (Choice == Selection.Version1)
        {
            anchorObject1.SetActive(true);
            anchorObject2_1.SetActive(true);
            anchorObject3_1.SetActive(true);
        }
        else if (Choice == Selection.Version2)
        {
            anchorObject1.SetActive(true);
            anchorObject2.SetActive(true);
            anchorObject3.SetActive(true);
            anchorObject4.SetActive(true);
            anchorObject5.SetActive(true);
        }
    }
 public void SendTimeServer(string type, string content)
 {
     TimeCost tc4 = new TimeCost(type, content);
     tCP.SocketSendByte(tc4);
 }