Esempio n. 1
0
 void OnGUI()
 {
     editString = GUI.TextField(new Rect(10, 10, 100, 20), editString);
     GUI.Label(new Rect(10, 30, 300, 20), tcpClient.GetRecvStr());
     if (GUI.Button(new Rect(10, 50, 60, 20), "send"))
     {
         tcpClient.SocketSend(editString);
     }
 }
Esempio n. 2
0
    private void init()
    {
        //StopAllCoroutines();
        //StartCoroutine("UpdateCoutine");


        tcpClient.SocketSend("1");
        string temp = tcpClient.GetRecvStr();

        string[] temps = temp.Split(';');
        NodeCode.text = "节点编号:" + temps[0];
        //GUI.Label(new Rect(10,70,300,20),"节点编号:"+tcpClient.GetRecvStr());
        tcpClient.SocketSend("2");
        LightStrength.text = "当前光强:" + temps[1];
        //GUI.Label(new Rect(10,90,300,20),"当前光强:"+tcpClient.GetRecvStr());
    }
Esempio n. 3
0
    public void recieve()
    {
        string returnData = client.GetRecvStr();

        if (returnData != null)
        {
            foreach (char ch in returnData)
            {
                switch (ch)
                {
                case protocol_begin:
                    buf_temp = "";
                    break;

                case protocol_end:
//					Debug.Log (buf_temp);
                    recieve_data.Enqueue(buf_temp);
                    break;

                default:
                    buf_temp += ch;
                    break;
                }
            }

            while (recieve_data.Count > 0)
            {
                string respone = recieve_data.Dequeue();

                Debug.Log("recieve data." + respone);

                NETWORK_DATA_PROTOCOL.Protocol protocol
                    = JsonConvert.DeserializeObject <NETWORK_DATA_PROTOCOL.Protocol>(respone);

                if (protocol.respone)
                {
                    //事件分发
                    SignalModule.SignalMgr.instance.Raise(get_signal((ulong)protocol.seq), respone);
                }
                else
                {
                    SignalModule.SignalMgr.instance.Raise((ulong)SignalModule.GAME_EVT.DATA_SYNC, respone);
                }
            }
        }
    }