Skip to content

Commit e500678

Browse files
Update install-sdk-web.md
Manage ACS SDK connectivity.
1 parent 6c2aa24 commit e500678

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 usually 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 will always try to stay connected and it will retry to reconnect continuously.
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, e.g. receiving incoming call notifications.
66+
- `Disconnected` - `Call Agent` instance is disconnected, this is a terminal state, `Call Agent` should be re-created, user should make sure it has no network problems.
67+
-- reason `invalidToken` - if token ACS token expired or is invalid and application failed to provide new valid token, `Call Agent` instance will disconnect with this reason.
68+
-- reason `connectionIssue` - if network is permanently down, and after many retries `Call Agent` fails to re-connect, it will permanently disconnect with this reason.

0 commit comments

Comments
 (0)