CommunicationRelayClient Class
Azure Communication Services Network Traversal client.
- Inheritance
-
builtins.objectCommunicationRelayClient
Constructor
CommunicationRelayClient(endpoint: str, credential: AsyncTokenCredential, **kwargs)
Parameters
- credential
- <xref:AsyncTokenCredential>
The AsyncTokenCredential we use to authenticate against the service.
Examples
: utf-8
-------------------------------------------------------------------
ght (c) Microsoft Corporation. All rights reserved.
ed under the MIT License. See License.txt in the project root for
e information.
--------------------------------------------------------------------
twork_traversal_samples_async.py
ION:
e samples demonstrate creating a user, issuing a token, revoking a token and deleting a user.
on network_traversal_samples.py
the environment variables with your own values before running the sample:
OMMUNICATION_SAMPLES_CONNECTION_STRING - the connection string in your ACS resource
ZURE_CLIENT_ID - the client ID of your active directory application
ZURE_CLIENT_SECRET - the secret of your active directory application
ZURE_TENANT_ID - the tenant ID of your active directory application
s
syncio
re.communication.networktraversal._shared.utils import parse_connection_str
mmunicationRelayClientSamples(object):
__init__(self):
self.connection_string = os.getenv('COMMUNICATION_SAMPLES_CONNECTION_STRING')
self.client_id = os.getenv('AZURE_CLIENT_ID')
self.client_secret = os.getenv('AZURE_CLIENT_SECRET')
self.tenant_id = os.getenv('AZURE_TENANT_ID')
c def get_relay_config(self):
from azure.communication.networktraversal.aio import CommunicationRelayClient
from azure.communication.identity.aio 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.aio 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)
async with identity_client:
print("Creating new user")
user = await identity_client.create_user()
print("User created with id:" + user.properties.get('id'))
async with relay_client:
print("Getting relay configuration")
relay_configuration = await relay_client.get_relay_configuration(user=user)
for iceServer in relay_configuration.ice_servers:
print("Icer server:")
print(iceServer)
f main():
le = CommunicationRelayClientSamples()
t sample.get_relay_config()
e__ == '__main__':
= asyncio.get_event_loop()
.run_until_complete(main())
Methods
| close |
Close the :class: ~azure.communication.networktraversal.aio.CommunicationRelayClient session. |
| from_connection_string |
Create CommunicationRelayClient from a Connection String. |
| get_relay_configuration |
get a Communication Relay configuration. :param user: Azure Communication User :type user: ~azure.communication.identity.CommunicationUserIdentifier :param route_type: Azure Communication Route Type :type route_type: ~azure.communication.networktraversal.RouteType :return: CommunicationRelayConfiguration :rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration |
close
Close the :class: ~azure.communication.networktraversal.aio.CommunicationRelayClient session.
async close() -> None
from_connection_string
Create CommunicationRelayClient from a Connection String.
from_connection_string(conn_str: str, **kwargs) -> azure.communication.networktraversal.aio._communication_relay_client_async.CommunicationRelayClient
Parameters
- conn_str
Returns
Instance of CommunicationRelayClient.
Return type
get_relay_configuration
get a Communication Relay configuration. :param user: Azure Communication User :type user: ~azure.communication.identity.CommunicationUserIdentifier :param route_type: Azure Communication Route Type :type route_type: ~azure.communication.networktraversal.RouteType :return: CommunicationRelayConfiguration :rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration
async get_relay_configuration(*, user: CommunicationUserIdentifier = None, route_type: Optional[Union[str, RouteType]] = None, **kwargs) -> CommunicationRelayConfiguration
Feedback
Submit and view feedback for