def get_relay_config(self):
        from azure.communication.networktraversal import (
            CommunicationRelayClient
        )
        from azure.communication.identity import (
            CommunicationIdentityClient
        )

        if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None:
            from azure.identity import DefaultAzureCredential
            endpoint, _ = parse_connection_str(self.connection_string)
            identity_client = CommunicationIdentityClient(endpoint, DefaultAzureCredential())
            relay_client = CommunicationRelayClient(endpoint, DefaultAzureCredential())
        else:
            identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
            relay_client = CommunicationRelayClient.from_connection_string(self.connection_string)
        
        print("Creating new user")
        user = identity_client.create_user()
        print("User created with id:" + user.properties.get('id'))

        print("Getting relay configuration")
        relay_configuration = relay_client.get_relay_configuration(user=user)

        for iceServer in relay_configuration.ice_servers:
            print("Icer server:")
            print(iceServer)
コード例 #2
0
    def test_get_relay_configuration_with_route_type_nearest(self, communication_livetest_dynamic_connection_string):
        identity_client = CommunicationIdentityClient.from_connection_string(
            communication_livetest_dynamic_connection_string,
            http_logging_policy=get_http_logging_policy()
        )
        user = identity_client.create_user()

        relay_client = CommunicationRelayClient.from_connection_string(
            communication_livetest_dynamic_connection_string,
            http_logging_policy=get_http_logging_policy()
        )

        print('Getting relay config with route type nearest:\n')
        config = relay_client.get_relay_configuration(user, RouteType.NEAREST)

        for iceServer in config.ice_servers:
            assert iceServer.username is not None
            print('Username: '******'Credential: ' + iceServer.credential)
            
            assert iceServer.urls is not None
            for url in iceServer.urls:
                print('Url: ' + url)

            print(iceServer.route_type)
            assert iceServer.route_type == RouteType.NEAREST

        assert config is not None
コード例 #3
0
    def test_get_relay_configuration(self, communication_livetest_dynamic_connection_string):
        identity_client = CommunicationIdentityClient.from_connection_string(
            communication_livetest_dynamic_connection_string,
            http_logging_policy=get_http_logging_policy()
        )
        user = identity_client.create_user()

        relay_client = CommunicationRelayClient.from_connection_string(
            communication_livetest_dynamic_connection_string,
            http_logging_policy=get_http_logging_policy()
        )

        print('Getting relay config:\n')
        config = relay_client.get_relay_configuration(user)
        
        print('Ice Servers: \n')
        for iceServer in config.ice_servers:
            assert iceServer.username is not None
            print('Username: '******'Credential: ' + iceServer.credential)
            
            assert iceServer.urls is not None
            for url in iceServer.urls:
                print('Url: ' + url)

        assert config is not None
        
コード例 #4
0
    def get_relay_config(self):

        identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
        relay_client = CommunicationRelayClient.from_connection_string(self.connection_string)
        
        print("Creating new user")
        user = identity_client.create_user()
        
        print("User created with id:" + user.properties.get('id'))

        print("Getting relay configuration")
        relay_configuration = relay_client.get_relay_configuration(user)

        for iceServer in relay_configuration.ice_servers:
            print("Ice server:")
            print(iceServer)

        # You can now setup the RTCPeerConnection
        iceServersList = []

        # Create the list of RTCIceServers
        for iceServer in relay_configuration.ice_servers:
            iceServersList.append(RTCIceServer(username = iceServer.username, credential=iceServer.credential, urls = iceServer.urls))

        # Initialize the RTCConfiguration
        config = RTCConfiguration(iceServersList)

        # Initialize the RTCPeerConnection 
        pc = RTCPeerConnection(config)
    def get_relay_config(self):

        relay_client = CommunicationRelayClient.from_connection_string(
            self.connection_string)

        print("Getting relay configuration")
        relay_configuration = relay_client.get_relay_configuration(
            route_type=RouteType.NEAREST)

        for iceServer in relay_configuration.ice_servers:
            print("Ice server:")
            print(iceServer)

        # You can now setup the RTCPeerConnection
        iceServersList = []

        # Create the list of RTCIceServers
        for iceServer in relay_configuration.ice_servers:
            iceServersList.append(
                RTCIceServer(username=iceServer.username,
                             credential=iceServer.credential,
                             urls=iceServer.urls))

        # Initialize the RTCConfiguration
        config = RTCConfiguration(iceServersList)

        # Initialize the RTCPeerConnection
        pc = RTCPeerConnection(config)
コード例 #6
0
    def get_relay_config_no_identity(self):
        from azure.communication.networktraversal import (
            CommunicationRelayClient)

        if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None:
            from azure.identity import DefaultAzureCredential
            endpoint, _ = parse_connection_str(self.connection_string)
            relay_client = CommunicationRelayClient(endpoint,
                                                    DefaultAzureCredential())
        else:
            relay_client = CommunicationRelayClient.from_connection_string(
                self.connection_string)

        print("Getting relay configuration")
        relay_configuration = relay_client.get_relay_configuration()

        for iceServer in relay_configuration.ice_servers:
            print("Icer server:")
            print(iceServer)
コード例 #7
0
    def test_get_relay_configuration_with_ttl(
            self, communication_livetest_dynamic_connection_string):

        relay_client = CommunicationRelayClient.from_connection_string(
            communication_livetest_dynamic_connection_string,
            http_logging_policy=get_http_logging_policy())

        expiry_time = 100

        # Make the request time to be time zome aware
        request_time = datetime.now() + timedelta(seconds=expiry_time)
        request_time = request_time.replace(tzinfo=timezone.utc)

        print('Getting relay config with a specified ttl:\n')
        config = relay_client.get_relay_configuration(ttl=expiry_time)

        assert config is not None

        print('Requested time:' +
              datetime.strftime(request_time, "%m/%d/%Y, %H:%M:%S"))
        print('Expires on:' +
              datetime.strftime(config.expires_on, "%m/%d/%Y, %H:%M:%S"))

        if self.is_live:
            assert request_time <= config.expires_on

        print('Ice Servers:\n')
        for iceServer in config.ice_servers:
            assert iceServer.username is not None
            print('Username: '******'Credential: ' + iceServer.credential)

            assert iceServer.urls is not None

            for url in iceServer.urls:
                print('Url: ' + url)

            print(iceServer.route_type)
            assert iceServer.route_type is not None