public void ProcessingData(byte[] data)
    {
        //  C_CommandBase command = new C_CommandBase(data);
        BaseDatatype baseType = new BaseDatatype(data);


        if (baseType.whom == CLIENT_NAME.CN_UNITY_1)
        {
            if (baseType.dataName == DATA_NAME.DN_TEST)
            {
                C_Test test = new C_Test(data);

                test.value[0]++;

                print(test.value[0].ToString());

                SendToServer(test.ToByteArray());
            }

            //             switch (command)
            //             {
            //
            //
            //                 //kun
            //                 case DATA_TYPE.DT_POINT:
            //                     C_KUN_POINT point = new C_KUN_POINT(data);
            //
            //                     Debug.Log(point.point[0].ToString() + point.point[1].ToString() + point.point[2].ToString());
            //
            //                     C_KUN_POINT kun_point = new C_KUN_POINT((int)CLIENT_NAME.CN_UNITY_1, (int)DATA_TYPE.DT_POINT, 1.111, 2.222, 3.333);
            //                     SendToServer(kun_point.ToByteArray());
            //
            //
            //                     break;
            //                 default:
            //                     Debug.Log("Unknown datatype");
            //                     break;
            //             }
        }

        else
        {
            Debug.Log("Unknown data");
        }
    }
Пример #2
0
    void OnGUI()
    {
        // if connection has not been made, display button to connect



        if (GUI.Button(new Rect(10, 10, 100, 100), "send test message"))
        {
            C_Test test = new C_Test(CLIENT_NAME.CN_UNITY_1, DATA_NAME.DN_TEST, DATA_TYPE.DT_POINT3);


            test.value[0] = 1.1;
            test.value[1] = 2.1;
            test.value[2] = 3.1;


            /*    C_Test test = new C_Test(CLIENT_NAME.CN_UNITY_1, (int)DATA_TYPE.DT_ARDUINO, 1);*/
            myTCP.SendToServer(test.ToByteArray());
        }
    }