Skip to content

Commit 49f41a6

Browse files
committed
feat: notify user via toast when the action was triggered
feat: only show the participant action in transcoded calls refactor: explain the usage of the generic senRequest API call in README.md
1 parent 5fd1b2c commit 49f41a6

File tree

4 files changed

+75
-38
lines changed

4 files changed

+75
-38
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ participant in the paricipant list. This allows the host user to set:
1414
- **Deny receive presentation**: Stop participant receiving presentation from the meeting
1515
- **Allow receive presentation**: Allow participant to receive presentation from the meeting (default)
1616

17+
The plugin relies on the generic API request: `plugin.conference.sendRequest`. This function is not typed published plugin-api package.
18+
19+
## Limitations
20+
21+
The plugin only works for transcoded meetings, it will not show up in direct media calls.
22+
1723
## Run for development
1824

1925
- To be able to build the plugin, you need to comply with the following versions

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,92 @@
1-
import { registerPlugin, type RPCCallPayload } from '@pexip/plugin-api'
1+
import {
2+
Button,
3+
InfinityParticipant,
4+
registerPlugin,
5+
type RPCCallPayload,
6+
} from "@pexip/plugin-api";
27

38
const plugin = await registerPlugin({
4-
id: 'rx-presentation',
5-
version: 0
6-
})
9+
id: "rx-presentation",
10+
version: 0,
11+
});
712

8-
const denyRxButtonPayload: RPCCallPayload<'ui:button:add'> = {
9-
position: 'participantActions',
10-
label: 'Deny receive presentation'
11-
}
13+
const denyRxButtonPayload: RPCCallPayload<"ui:button:add"> = {
14+
position: "participantActions",
15+
label: "Deny receive presentation",
16+
};
1217

13-
const allowRxButtonPayload: RPCCallPayload<'ui:button:add'> = {
14-
position: 'participantActions',
15-
label: 'Allow receive presentation'
16-
}
18+
const allowRxButtonPayload: RPCCallPayload<"ui:button:add"> = {
19+
position: "participantActions",
20+
label: "Allow receive presentation",
21+
};
1722

18-
const denyRxButton = await plugin.ui.addButton(denyRxButtonPayload)
19-
const allowRxButton = await plugin.ui.addButton(allowRxButtonPayload)
23+
let isDirectMedia: boolean | undefined = undefined;
24+
25+
let participantList: Map<string, InfinityParticipant> = new Map();
26+
27+
const denyRxButton = await plugin.ui.addButton(denyRxButtonPayload);
28+
const allowRxButton = await plugin.ui.addButton(allowRxButtonPayload);
2029

2130
denyRxButton.onClick.add(async ({ participantUuid }) => {
2231
const payload = {
2332
path: "participants/" + participantUuid + "/denyrxpresentation",
2433
method: "POST",
25-
payload: {}
34+
payload: {},
2635
};
2736
await plugin.conference.sendRequest(payload);
28-
})
37+
plugin.ui.showToast({
38+
message:
39+
"Denying receive presentation for " +
40+
participantList.get(participantUuid)?.displayName,
41+
});
42+
});
2943

3044
allowRxButton.onClick.add(async ({ participantUuid }) => {
3145
const payload = {
3246
path: "participants/" + participantUuid + "/allowrxpresentation",
3347
method: "POST",
34-
payload: {}
48+
payload: {},
3549
};
3650
await plugin.conference.sendRequest(payload);
37-
})
51+
plugin.ui.showToast({
52+
message:
53+
"Allowing receive presentation for " +
54+
participantList.get(participantUuid)?.displayName,
55+
});
56+
});
3857

39-
plugin.events.participants.add(({ participants }) => {
58+
plugin.events.conferenceStatus.add(async ({ status }) => {
59+
isDirectMedia = status.directMedia;
60+
});
61+
62+
const updateParticipantButtons = (participants: InfinityParticipant[]) => {
4063
const allowedRxParticipants = participants
41-
.filter((participant) => participant.rxPresentation)
42-
.map((participant) => participant.uuid)
64+
.filter((participant) => participant.rxPresentation && !isDirectMedia)
65+
.map((participant) => participant.uuid);
4366

4467
const deniedRxParticipants = participants
45-
.filter((participant) => !participant.rxPresentation)
46-
.map((participant) => participant.uuid)
68+
.filter((participant) => !participant.rxPresentation && !isDirectMedia)
69+
.map((participant) => participant.uuid);
4770

4871
denyRxButton
4972
.update({
5073
...denyRxButtonPayload,
51-
participantIDs: allowedRxParticipants
74+
participantIDs: allowedRxParticipants,
5275
})
53-
.catch(console.error)
76+
.catch(console.error);
5477

5578
allowRxButton
5679
.update({
5780
...allowRxButtonPayload,
58-
participantIDs: deniedRxParticipants
81+
participantIDs: deniedRxParticipants,
5982
})
60-
.catch(console.error)
61-
})
83+
.catch(console.error);
84+
};
85+
86+
plugin.events.participants.add(({ participants }) => {
87+
participantList = new Map();
88+
participants.forEach((participant) =>
89+
participantList.set(participant.uuid, participant)
90+
);
91+
updateParticipantButtons(participants);
92+
});

tsconfig.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"compilerOptions": {
3-
"target": "ESNext",
4-
"module": "ESNext",
5-
"moduleResolution": "node",
6-
"esModuleInterop": true,
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "node",
6+
"esModuleInterop": true,
77
"forceConsistentCasingInFileNames": true,
8-
"resolveJsonModule": true,
9-
"strict": true,
8+
"resolveJsonModule": true,
9+
"strict": true,
1010
"skipLibCheck": true
1111
}
12-
}
12+
}

0 commit comments

Comments
 (0)