예제 #1
0
        public IEnumerator CheckPeerExists()
        {
            bool startRaised1 = false;
            bool startRaised2 = false;

            signaling1.OnStart += s => { startRaised1 = true; };
            signaling1.Start();
            signaling2.OnStart += s => { startRaised2 = true; };
            signaling2.Start();

            yield return(new WaitUntil(() => startRaised1 && startRaised2));

            const string connectionId         = "12345";
            string       receiveConnectionId1 = null;
            string       receiveConnectionId2 = null;
            bool         receivePeerExists1   = false;
            bool         receivePeerExists2   = false;

            signaling1.OnCreateConnection += (s, id, peerExists) =>
            {
                receiveConnectionId1 = id;
                receivePeerExists1   = peerExists;
            };
            signaling1.OpenConnection(connectionId);
            yield return(new WaitUntil(() => !string.IsNullOrEmpty(receiveConnectionId1)));

            Assert.AreEqual(connectionId, receiveConnectionId1);
            Assert.IsFalse(receivePeerExists1);

            signaling2.OnCreateConnection += (s, id, peerExists) =>
            {
                receiveConnectionId2 = id;
                receivePeerExists2   = peerExists;
            };
            signaling2.OpenConnection(connectionId);
            yield return(new WaitUntil(() => !string.IsNullOrEmpty(receiveConnectionId2)));

            Assert.AreEqual(connectionId, receiveConnectionId2);
            Assert.IsTrue(receivePeerExists2);

            signaling1.CloseConnection(receiveConnectionId1);
            signaling2.CloseConnection(receiveConnectionId2);
            signaling1.Stop();
            signaling2.Stop();
            yield return(new WaitForSeconds(1));
        }
예제 #2
0
        public IEnumerator OnOffer()
        {
            bool         startRaised1    = false;
            bool         startRaised2    = false;
            bool         offerRaised     = false;
            bool         raiseOnDestroy1 = false;
            bool         raiseOnDestroy2 = false;
            string       connectionId1   = null;
            string       connectionId2   = null;
            const string _connectionId   = "12345";

            signaling1.OnStart += s => { startRaised1 = true; };
            signaling2.OnStart += s => { startRaised2 = true; };
            signaling1.Start();
            signaling2.Start();
            yield return(new WaitUntil(() => startRaised1 && startRaised2));

            signaling1.OnCreateConnection += (s, connectionId, polite) => {
                connectionId1 = connectionId;
            };
            signaling1.OnDestroyConnection += (signaling, id) =>
            {
                raiseOnDestroy1 = id == connectionId1;
            };
            signaling1.OpenConnection(_connectionId);

            signaling2.OnCreateConnection += (s, connectionId, polite) => {
                connectionId2 = connectionId;
            };
            signaling1.OnDestroyConnection += (signaling, id) =>
            {
                raiseOnDestroy2 = id == connectionId2;
            };
            signaling2.OpenConnection(_connectionId);
            yield return(new WaitUntil(() =>
                                       !string.IsNullOrEmpty(connectionId1) && !string.IsNullOrEmpty(connectionId2)));

            Assert.That(connectionId1, Is.EqualTo(_connectionId));
            Assert.That(connectionId2, Is.EqualTo(_connectionId));

            signaling2.OnOffer += (s, e) => { offerRaised = true; };
            signaling1.SendOffer(connectionId1, m_DescOffer);
            yield return(new WaitUntil(() => offerRaised));

            signaling1.CloseConnection(connectionId1);

            yield return(new WaitUntil(() => raiseOnDestroy1 && raiseOnDestroy2));

            Assert.That(raiseOnDestroy1, Is.True);
            Assert.That(raiseOnDestroy2, Is.True);
        }
예제 #3
0
 public void CloseConnection(string connectionId)
 {
     m_signaling?.CloseConnection(connectionId);
 }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connectionId"></param>
 public void DeleteConnection(string connectionId)
 {
     _signaling.CloseConnection(connectionId);
 }
예제 #5
0
        public IEnumerator OnConnect()
        {
            bool startRaised1 = false;
            bool startRaised2 = false;

            signaling1.OnStart += s => { startRaised1 = true; };
            signaling1.Start();
            signaling2.OnStart += s => { startRaised2 = true; };
            signaling2.Start();

            yield return(new WaitUntil(() => startRaised1 && startRaised2));

            const string connectionId         = "12345";
            string       receiveConnectionId1 = null;
            string       receiveConnectionId2 = null;
            bool         receivePolite1       = false;
            bool         receivePolite2       = false;
            bool         raiseOnDestroy1      = false;
            bool         raiseOnDestroy2      = false;

            signaling1.OnCreateConnection += (s, id, polite) =>
            {
                receiveConnectionId1 = id;
                receivePolite1       = polite;
            };
            signaling1.OnDestroyConnection += (signaling, id) =>
            {
                raiseOnDestroy1 = id == receiveConnectionId1;
            };
            signaling1.OpenConnection(connectionId);
            yield return(new WaitUntil(() => !string.IsNullOrEmpty(receiveConnectionId1)));

            signaling2.OnCreateConnection += (s, id, polite) =>
            {
                receiveConnectionId2 = id;
                receivePolite2       = polite;
            };
            signaling2.OnDestroyConnection += (signaling, id) =>
            {
                raiseOnDestroy2 = id == receiveConnectionId2;
            };
            signaling2.OpenConnection(connectionId);
            yield return(new WaitUntil(() => !string.IsNullOrEmpty(receiveConnectionId2)));

            Assert.That(receiveConnectionId1, Is.EqualTo(connectionId));
            Assert.That(receiveConnectionId2, Is.EqualTo(connectionId));
            Assert.That(receivePolite1, Is.False);
            Assert.That(receivePolite2, Is.True);

            // wait first connection list on http
            yield return(new WaitForSeconds(1));

            signaling1.CloseConnection(receiveConnectionId1);

            yield return(new WaitUntil(() => raiseOnDestroy1 && raiseOnDestroy2));

            Assert.That(raiseOnDestroy1, Is.True);
            Assert.That(raiseOnDestroy2, Is.True);

            signaling2.CloseConnection(receiveConnectionId2);
            signaling1.Stop();
            signaling2.Stop();
            yield return(new WaitForSeconds(1));
        }