public IEnumerator BuildOffer() { m_rtwRTCWrapper.MakeOffer(); while (m_rtwRTCWrapper.WebRtcObjectState == WebRTCWrapper.State.MakingOffer) { yield return(null); } }
public IEnumerator WebRtcNativeTestWithEnumeratorPasses() { //IPeer nativePeer1 = new NativePeer(IceServers.Select(i => i.ToString()).ToList(), string.Empty, string.Empty); //IPeer nativePeer2 = new NativePeer(IceServers.Select(i => i.ToString()).ToList(), string.Empty, string.Empty); IPeer nativePeer1 = new SocketsPeer(); IPeer nativePeer2 = new SocketsPeer(); WebRTCWrapper wrwPeer1 = new WebRTCWrapper(nativePeer1); WebRTCWrapper wrwPeer2 = new WebRTCWrapper(nativePeer2); //create offer wrwPeer1.MakeOffer(); Debug.Log("Offer Started waiting for ice"); //wait for offer to finieh while (wrwPeer1.WebRtcObjectState == WebRTCWrapper.State.MakingOffer) { yield return(null); } Debug.Log($"Offer finished {wrwPeer1.m_iceOfferIceCandidates.Count} ice candidates created"); //send offer to connection 2 wrwPeer2.ProcessOfferAndMakeReply(wrwPeer1.m_ofrOffer.m_strValue); DateTime now = DateTime.UtcNow; while ((DateTime.UtcNow - now).TotalSeconds < 3) { yield return(null); } Debug.Log("Reply started"); //send all ice candidates for (int i = 0; i < wrwPeer1.m_iceOfferIceCandidates.Count; i++) { Debug.Log("processing Ice Candidate sent to peer 2"); WebRTCWrapper.IceCandidate ice = wrwPeer1.m_iceOfferIceCandidates[i]; wrwPeer2.AddICE(ice.m_strType, ice.m_iIndex, ice.m_strValue); } Debug.Log("Ice Candidate processing finished Reply started, waiting for ice"); //wait for reply to finish while (wrwPeer2.WebRtcObjectState == WebRTCWrapper.State.MakingReply) { yield return(null); } Debug.Log($"Reply ice finished {wrwPeer2.m_iceOfferIceCandidates.Count} ice candidates created sending answer"); //send reply back to source wrwPeer1.ProcessReply(wrwPeer2.m_repReply.m_strValue); now = DateTime.UtcNow; while ((DateTime.UtcNow - now).TotalSeconds < 3) { yield return(null); } Debug.Log("Answer process finished waiting on ice processing"); //process all the ice candidates for (int i = 0; i < wrwPeer2.m_iceOfferIceCandidates.Count; i++) { Debug.Log("processing Ice Candidate sent to peer 1"); WebRTCWrapper.IceCandidate ice = wrwPeer2.m_iceOfferIceCandidates[i]; wrwPeer1.AddICE(ice.m_strType, ice.m_iIndex, ice.m_strValue); } Debug.Log("Ice processing finished waiting for connection"); now = DateTime.UtcNow; while ((DateTime.UtcNow - now).TotalSeconds < 5) { //wait for connection to succeed yield return(null); } //check connection status Debug.Assert(wrwPeer1.WebRtcObjectState == WebRTCWrapper.State.Conncted, "Peer 1 failed to connect"); Debug.Assert(wrwPeer2.WebRtcObjectState == WebRTCWrapper.State.Conncted, "Peer 2 failed to connect"); wrwPeer1.SendData("Test 1"); wrwPeer2.SendData("Test 2"); now = DateTime.UtcNow; while ((DateTime.UtcNow - now).TotalSeconds < 5) { //wait for message test yield return(null); } yield return(null); }