Beispiel #1
0
    def test_connect_fail(self):
        gatherer_1 = RTCIceGatherer()
        transport_1 = RTCIceTransport(gatherer_1)

        gatherer_2 = RTCIceGatherer()
        transport_2 = RTCIceTransport(gatherer_2)

        # gather candidates
        run(asyncio.gather(gatherer_1.gather(), gatherer_2.gather()))
        for candidate in gatherer_2.getLocalCandidates():
            run(transport_1.addRemoteCandidate(candidate))
        for candidate in gatherer_1.getLocalCandidates():
            run(transport_2.addRemoteCandidate(candidate))
        self.assertEqual(transport_1.state, "new")
        self.assertEqual(transport_2.state, "new")

        # connect
        run(transport_2.stop())
        run(transport_1.start(gatherer_2.getLocalParameters()))
        self.assertEqual(transport_1.state, "failed")
        self.assertEqual(transport_2.state, "closed")

        # cleanup
        run(asyncio.gather(transport_1.stop(), transport_2.stop()))
        self.assertEqual(transport_1.state, "closed")
        self.assertEqual(transport_2.state, "closed")
 def test_gather(self):
     gatherer = RTCIceGatherer()
     self.assertEqual(gatherer.state, "new")
     self.assertEqual(gatherer.getLocalCandidates(), [])
     run(gatherer.gather())
     self.assertEqual(gatherer.state, "completed")
     self.assertTrue(len(gatherer.getLocalCandidates()) > 0)
    def test_connect(self):
        gatherer_1 = RTCIceGatherer()
        transport_1 = RTCIceTransport(gatherer_1)

        gatherer_2 = RTCIceGatherer()
        transport_2 = RTCIceTransport(gatherer_2)

        # gather candidates
        run(asyncio.gather(gatherer_1.gather(), gatherer_2.gather()))
        for candidate in gatherer_2.getLocalCandidates():
            transport_1.addRemoteCandidate(candidate)
        for candidate in gatherer_1.getLocalCandidates():
            transport_2.addRemoteCandidate(candidate)
        self.assertEqual(transport_1.state, 'new')
        self.assertEqual(transport_2.state, 'new')

        # connect
        run(
            asyncio.gather(transport_1.start(gatherer_2.getLocalParameters()),
                           transport_2.start(gatherer_1.getLocalParameters())))
        self.assertEqual(transport_1.state, 'completed')
        self.assertEqual(transport_2.state, 'completed')

        # cleanup
        run(asyncio.gather(transport_1.stop(), transport_2.stop()))
        self.assertEqual(transport_1.state, 'closed')
        self.assertEqual(transport_2.state, 'closed')
    async def test_connect(self):
        gatherer_1 = RTCIceGatherer()
        transport_1 = RTCIceTransport(gatherer_1)

        gatherer_2 = RTCIceGatherer()
        transport_2 = RTCIceTransport(gatherer_2)

        # gather candidates
        await asyncio.gather(gatherer_1.gather(), gatherer_2.gather())
        for candidate in gatherer_2.getLocalCandidates():
            await transport_1.addRemoteCandidate(candidate)
        for candidate in gatherer_1.getLocalCandidates():
            await transport_2.addRemoteCandidate(candidate)
        self.assertEqual(transport_1.state, "new")
        self.assertEqual(transport_2.state, "new")

        # connect
        await asyncio.gather(
            transport_1.start(gatherer_2.getLocalParameters()),
            transport_2.start(gatherer_1.getLocalParameters()),
        )
        self.assertEqual(transport_1.state, "completed")
        self.assertEqual(transport_2.state, "completed")

        # cleanup
        await asyncio.gather(transport_1.stop(), transport_2.stop())
        self.assertEqual(transport_1.state, "closed")
        self.assertEqual(transport_2.state, "closed")
    async def test_gather(self):
        gatherer = RTCIceGatherer()
        self.assertEqual(gatherer.state, "new")
        self.assertEqual(gatherer.getLocalCandidates(), [])
        await gatherer.gather()
        self.assertEqual(gatherer.state, "completed")
        self.assertTrue(len(gatherer.getLocalCandidates()) > 0)

        # close
        await gatherer._connection.close()
 def test_construct(self):
     gatherer = RTCIceGatherer()
     self.assertEqual(gatherer.state, 'new')
     self.assertEqual(gatherer.getLocalCandidates(), [])
     run(gatherer.gather())
     self.assertTrue(len(gatherer.getLocalCandidates()) > 0)