Ejemplo n.º 1
0
        public void GetRelayConfiguration()
        {
            var connectionString = TestEnvironment.LiveTestDynamicConnectionString;

            var communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();
            Response <CommunicationUserIdentifier> response = communicationIdentityClient.CreateUser();
            var user = response.Value;

            #region Snippet:CreateCommunicationRelayClient
            // Get a connection string to our Azure Communication resource.
            //@@var connectionString = "<connection_string>";
            var client = new CommunicationRelayClient(connectionString);
            #endregion Snippet:CreateCommunicationRelayClient
            client = CreateClientWithConnectionString();

            #region Snippet:GetRelayConfiguration
            Response <CommunicationRelayConfiguration> turnTokenResponse = client.GetRelayConfiguration(user);
            DateTimeOffset turnTokenExpiresOn = turnTokenResponse.Value.ExpiresOn;
            IReadOnlyList <CommunicationTurnServer> turnServers = turnTokenResponse.Value.TurnServers;
            Console.WriteLine($"Expires On: {turnTokenExpiresOn}");
            foreach (CommunicationTurnServer turnServer in turnServers)
            {
                foreach (string url in turnServer.Urls)
                {
                    Console.WriteLine($"TURN Url: {url}");
                }
                Console.WriteLine($"TURN Username: {turnServer.Username}");
                Console.WriteLine($"TURN Credential: {turnServer.Credential}");
            }
            #endregion Snippet:GetRelayConfiguration
        }
        public void GetRelayConfigurationWithNearestRouteType()
        {
            var connectionString = TestEnvironment.LiveTestDynamicConnectionString;

            var communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();
            Response <CommunicationUserIdentifier> response = communicationIdentityClient.CreateUser();
            var user = response.Value;

            // Get a connection string to our Azure Communication resource.
            //@@var connectionString = "<connection_string>";
            var client = new CommunicationRelayClient(connectionString);

            client = CreateClientWithConnectionString();

            Response <CommunicationRelayConfiguration> relayConfiguration = client.GetRelayConfiguration(new GetRelayConfigurationOptions {
                CommunicationUser = user, RouteType = RouteType.Nearest
            });
            DateTimeOffset turnTokenExpiresOn = relayConfiguration.Value.ExpiresOn;
            IReadOnlyList <CommunicationIceServer> iceServers = relayConfiguration.Value.IceServers;

            Console.WriteLine($"Expires On: {turnTokenExpiresOn}");
            foreach (CommunicationIceServer iceServer in iceServers)
            {
                foreach (string url in iceServer.Urls)
                {
                    Console.WriteLine($"ICE Server Url: {url}");
                }
                Console.WriteLine($"ICE Server Username: {iceServer.Username}");
                Console.WriteLine($"ICE Server Credential: {iceServer.Credential}");
                Console.WriteLine($"ICE Server RouteType: {iceServer.RouteType}");
            }
        }
Ejemplo n.º 3
0
        public void GetRelayConfigurationWithoutIdentity()
        {
            var connectionString = TestEnvironment.LiveTestDynamicConnectionString;

            // Get a connection string to our Azure Communication resource.
            //@@var connectionString = "<connection_string>";
            var client = new CommunicationRelayClient(connectionString);

            client = CreateClientWithConnectionString();

            #region Snippet:GetRelayConfiguration
            Response <CommunicationRelayConfiguration> relayConfiguration = client.GetRelayConfiguration();
            DateTimeOffset turnTokenExpiresOn         = relayConfiguration.Value.ExpiresOn;
            IList <CommunicationIceServer> iceServers = relayConfiguration.Value.IceServers;
            Console.WriteLine($"Expires On: {turnTokenExpiresOn}");
            foreach (CommunicationIceServer iceServer in iceServers)
            {
                foreach (string url in iceServer.Urls)
                {
                    Console.WriteLine($"ICE Server Url: {url}");
                }
                Console.WriteLine($"ICE Server Username: {iceServer.Username}");
                Console.WriteLine($"ICE Server Credential: {iceServer.Credential}");
                Console.WriteLine($"ICE Server RouteType: {iceServer.RouteType}");
            }
            #endregion Snippet:GetRelayConfiguration
        }
        public static CommunicationRelayConfiguration GetRelayConfiguration()
        {
            Response <CommunicationRelayConfiguration> relayConfiguration = _communicationRelayClient.GetRelayConfiguration();
            DateTimeOffset turnTokenExpiresOn = relayConfiguration.Value.ExpiresOn;
            IReadOnlyList <CommunicationIceServer> iceServers = (IReadOnlyList <CommunicationIceServer>)relayConfiguration.Value.IceServers;

            Console.WriteLine($"Expires On: {turnTokenExpiresOn}");
            foreach (CommunicationIceServer iceServer in iceServers)
            {
                foreach (string url in iceServer.Urls)
                {
                    Console.WriteLine($"ICE Server Url: {url}");
                }
                Console.WriteLine($"ICE Server Username: {iceServer.Username}");
                Console.WriteLine($"ICE Server Credential: {iceServer.Credential}");
                Console.WriteLine($"ICE Server RouteType: {iceServer.RouteType}");
            }

            return(relayConfiguration);
        }