Skip to content

Commit 89d4103

Browse files
authored
Merge pull request #273724 from sharifrahaman/patch-4
Update install-sdk-web.md
2 parents 63dd5d5 + 6f0833b commit 89d4103

File tree

1 file changed

+23
-0
lines changed
  • articles/communication-services/how-tos/calling-sdk/includes/install-sdk

1 file changed

+23
-0
lines changed

articles/communication-services/how-tos/calling-sdk/includes/install-sdk/install-sdk-web.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,26 @@ const tokenCredential = new AzureCommunicationTokenCredential(userToken);
4343
const callAgent = await callClient.createCallAgent(tokenCredential, {displayName: 'optional Azure Communication Services user name'});
4444
const deviceManager = await callClient.getDeviceManager()
4545
```
46+
47+
### Manage ACS SDK connectivity for incoming calls
48+
49+
A `Call Agent` instance lets you start/join and manage incoming calls. Your `Call Agent` instance needs to be connected to ACS infrastructure to receive incoming calls. This connection is established when a `Call Agent` instance is created, but sometimes, for example when the network is unstable, the connection may not be set up, or it may break during the lifecycle of `Call Agent`. ACS SDK always tries to stay connected with ACS infrastructure. It keeps retrying to connect when the connection is lost.
50+
51+
You can check if `Call Agent` is connected to ACS infra by looking at the current value of `connectionState` property and listening to `connectionStateChanged` event from `Call Agent`.
52+
53+
```js
54+
const connectionState = callAgentInstance.connectionState;
55+
console.log(connectionState); // it may return either of 'Connected' | 'Disconnected'
56+
57+
const connectionStateCallback = (args) => {
58+
console.log(args); // it will return an object with oldState and newState, each of having a value of either of 'Connected' | 'Disconnected'
59+
// it will also return reason, either of 'invalidToken' | 'connectionIssue'
60+
}
61+
callAgentInstance.on('connectionStateChanged', connectionStateCallback);
62+
```
63+
64+
The above example illustrates how to manage connection state, whenever connection state is:
65+
- `Connected` - `Call Agent` instance is connected and capable of receiving notification from ACS infra. For example, receiving incoming call notifications.
66+
- `Disconnected` - `Call Agent` instance is disconnected. It is a terminal state. `Call Agent` should be re-created. Users should make sure it has no network problems.
67+
-- reason `invalidToken` - if ACS token expired or it's invalid and application failed to provide new valid token. `Call Agent` instance will disconnect with this reason.
68+
-- reason `connectionIssue` - if the network is down, and after many retries `Call Agent` fails to re-connect, it will disconnect with this reason. It usually indicates client network issues and can be re-stored as soon as the connectivity issue is resolved.

0 commit comments

Comments
 (0)