Skip to content

Commit 92e364f

Browse files
authored
Create raise-hand-web.md
1 parent 6a744fb commit 92e364f

File tree

1 file changed

+85
-0
lines changed
  • articles/communication-services/how-tos/calling-sdk/includes/raise-hand

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
author: ruslanzdor
3+
ms.service: azure-communication-services
4+
ms.topic: include
5+
ms.date: 09/08/2022
6+
ms.author: rifox
7+
---
8+
[!INCLUDE [Install SDK](../install-sdk/install-sdk-web.md)]
9+
10+
> [!NOTE]
11+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. To use this api please use 'beta' release of Azure Communication Services Calling Web SDK
12+
13+
Raise Hand is an extended feature of the core `Call` API. You first need to import calling Features from the Calling SDK:
14+
15+
```js
16+
import { Features} from "@azure/communication-calling";
17+
```
18+
19+
Then you can get the feature API object from the call instance:
20+
21+
```js
22+
const raiseHandFeature = call.feature(Features.RaiseHand );
23+
```
24+
25+
### Raise and Lower Hand for current participant:
26+
Raise Hand state can be used this any call type: on 1:1 calls and on calls with many participants, in ACS and in Teams calls.
27+
If it Teams meeting - organizer will have ability to enable or disable raise hand states for all participants.
28+
To change state for current participant you can use methods:
29+
```js
30+
const raiseHandFeature = call.feature(Features.RaiseHand );
31+
//raise
32+
raiseHandFeature.raiseHand();
33+
//lower
34+
raiseHandFeature.lowerHand();
35+
```
36+
37+
### Lower hands for other participants
38+
Currently ACS calls are not allow to change state of other participants, for example, lower all hands. But on Teams calls is can be done using this methods:
39+
```js
40+
const raiseHandFeature = call.feature(Features.RaiseHand );
41+
//lower all hands on the call
42+
raiseHandFeature.lowerHandForEveryone();
43+
//or we can provide array of CommunicationIdentifier to specify list of participants
44+
CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>);
45+
MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>)
46+
CommunicationIdentifier participants[] = new CommunicationIdentifier[]{ acsUser, teamsUser };
47+
raiseHandFeature.lowerHand(participants);
48+
```
49+
50+
### Handle changed states
51+
The `Raise Hand` API allows you to subscribe to `raiseHandChanged` events. A `raiseHandChanged` event comes from a `call` instance and contain information about participant and his new state.
52+
```js
53+
const raiseHandFeature = call.feature(Features.RaiseHand );
54+
55+
// event : {identifier: CommunicationIdentifier, isRaised: true, order:1}
56+
const isRaiseHandChangedHandler = (event) => {
57+
console.log(`Participant ${event.identifier} ${event.isRaised ? "Raised" : "Lower"} his hand`);
58+
};
59+
raiseHandFeature.feature(SDK.Features.RaiseHand).on('raiseHandChanged', isRaiseHandChangedHandler):
60+
```
61+
62+
### List of all participants with active state
63+
To get information about all participants that have Raise Hand state on current call you can use this api array is sorted by order field:
64+
```js
65+
const raiseHandFeature = call.feature(Features.RaiseHand );
66+
let activeStates = raiseHandFeature.getStatus();
67+
```
68+
69+
### Order of Raised Hands
70+
It possible to get order of all raised hand states on the call, this order is started from 1.
71+
To get it there is two ways: get all raise hand state on the call or use `raiseHandChanged` event subscription.
72+
In case of event subscription when any participant will lower a hand - call will generate only one event, but not for all participants with order above.
73+
74+
```js
75+
const raiseHandFeature = call.feature(Features.RaiseHand );
76+
77+
// event : {identifier: CommunicationIdentifier, isRaised: true, order:1}
78+
const isRaiseHandChangedHandler = (event) => {
79+
console.log(`List of participants with raised hand`);
80+
for (let state : raiseHandFeature.getStatus()) {
81+
console.log(`Participant ${state.identifier} has order ${state.order}`);
82+
}
83+
};
84+
raiseHandFeature.feature(SDK.Features.RaiseHand).on('raiseHandChanged', isRaiseHandChangedHandler):
85+
```

0 commit comments

Comments
 (0)