Пример #1
0
 void Dispose()
 {
     dropdown.options      = new List <Dropdown.OptionData>();
     dropdown.interactable = false;
     text.text             = string.Empty;
     text.interactable     = false;
     dataChannel.Dispose();
     pc1.Dispose();
     pc2.Dispose();
 }
        public IEnumerator PeerConnection_SetRemoteDescription()
        {
            RTCConfiguration config = default;

            config.iceServers = new[] { new RTCIceServer {
                                            urls = new[] { "stun:stun.l.google.com:19302" }
                                        } };
            var            peer1    = new RTCPeerConnection(ref config);
            var            peer2    = new RTCPeerConnection(ref config);
            RTCDataChannel channel1 = null;

            var conf = new RTCDataChannelInit(true);

            channel1 = peer1.CreateDataChannel("data", ref conf);

            RTCOfferOptions  options1 = default;
            RTCAnswerOptions options2 = default;
            var op1 = peer1.CreateOffer(ref options1);

            yield return(op1);

            var op2 = peer1.SetLocalDescription(ref op1.desc);

            yield return(op2);

            var op3 = peer2.SetRemoteDescription(ref op1.desc);

            yield return(op3);

            var op4 = peer2.CreateAnswer(ref options2);

            yield return(op4);

            var op5 = peer2.SetLocalDescription(ref op4.desc);

            yield return(op5);

            var op6 = peer1.SetRemoteDescription(ref op4.desc);

            yield return(op6);

            channel1.Dispose();
            peer1.Dispose();
            peer2.Dispose();
        }
        public IEnumerator UnityTearDown()
        {
            _target1.DeleteConnection(connectionId);
            _target2.DeleteConnection(connectionId);

            bool isDeletedConnection1 = false;
            bool isDeletedConnection2 = false;

            _target1.onDeletedConnection += _ => { isDeletedConnection1 = true; };
            _target2.onDeletedConnection += _ => { isDeletedConnection2 = true; };
            yield return(new WaitUntil(() => isDeletedConnection1 && isDeletedConnection2));

            _channel1.Dispose();
            _channel2.Dispose();

            _test.component.StopAllCoroutines();
            UnityEngine.Object.Destroy(_test.gameObject);
        }
Пример #4
0
 void Dispose()
 {
     dataChannel.Dispose();
     pc1.Dispose();
     pc2.Dispose();
 }
Пример #5
0
 public void Dispose()
 {
     dataChannel.Dispose();
     peers[0].Close();
     peers[1].Close();
 }