IEnumerator receiveWithLag() { while (true) { yield return(new WaitForSeconds(0.05f)); if (minUdpClient.Available > 0) { yield return(new WaitForSeconds(0.1f)); Debug.Log("receive data"); receiveBytes = minUdpClient.Receive(ref RemoteIpEndPoint); status.text = ("connected " + RemoteIpEndPoint.ToString()); RecordVoice.playSound(receiveBytes); } } }
IEnumerator receive() { while (true) { yield return(new WaitForSeconds(0.0005f)); if (minUdpClient.Available > 0) { try { Debug.Log("receive data"); receiveBytes = minUdpClient.Receive(ref RemoteIpEndPoint); status.text = ("connected " + RemoteIpEndPoint.ToString()); RecordVoice.playSound(receiveBytes); } catch (Exception e) { //Debug.Log(String.Format("Error: {0}", e.Message)); status.text = ("connecting problem " + e.Message); } } } }