IEnumerator SampleCo() { while (true) { if (tcpNetComp.State == "connected") { List <string> msgList = tcpNetComp.RecvString(); tcpSingal = msgList.Count / 5f; } if (kcpNetComp.State == "connected") { List <string> msgList = kcpNetComp.RecvString(); kcpSingal = msgList.Count / 5f; } if (udpNetComp.State == "connected") { List <string> msgList = udpNetComp.RecvString(); udpSingal = msgList.Count / 5f; } string data = string.Format("{0} {1} {2}\r\n", tcpSingal, kcpSingal, udpSingal); byte[] chunk = Encoding.UTF8.GetBytes(data); singalFileStream.Write(chunk, 0, chunk.Length); yield return(new WaitForSeconds(sampleInterval)); } }
// Update is called once per frame void Update() { List <string> msgList = udpNetComp.RecvString(); foreach (var msg in msgList) { Debug.Log("recv " + msg); } }