@cometchat/skills 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/bin/install.js +448 -57
- package/package.json +1 -1
- package/skills/cometchat/SKILL.md +337 -80
- package/skills/cometchat-a11y/SKILL.md +476 -0
- package/skills/cometchat-android-v5/SKILL.md +1 -1
- package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
- package/skills/cometchat-android-v5-calls/references/README.md +53 -0
- package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
- package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
- package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
- package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
- package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
- package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
- package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
- package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
- package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
- package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
- package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
- package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
- package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
- package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
- package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
- package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
- package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
- package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
- package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
- package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
- package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
- package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
- package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
- package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
- package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
- package/skills/cometchat-android-v5-components/SKILL.md +1 -1
- package/skills/cometchat-android-v5-core/SKILL.md +1 -1
- package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v5-features/SKILL.md +1 -1
- package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v5-production/SKILL.md +1 -1
- package/skills/cometchat-android-v5-push/SKILL.md +1 -1
- package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-android-v6/SKILL.md +1 -1
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
- package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
- package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
- package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
- package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
- package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
- package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
- package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
- package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
- package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
- package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
- package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
- package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-core/SKILL.md +1 -1
- package/skills/cometchat-android-v6-events/SKILL.md +1 -1
- package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v6-features/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
- package/skills/cometchat-android-v6-production/SKILL.md +1 -1
- package/skills/cometchat-android-v6-push/SKILL.md +1 -1
- package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-angular-calls/SKILL.md +511 -0
- package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
- package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
- package/skills/cometchat-angular-calls/references/call-session.md +167 -0
- package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
- package/skills/cometchat-angular-calls/references/device-management.md +135 -0
- package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
- package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
- package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
- package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
- package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
- package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
- package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
- package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
- package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
- package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
- package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
- package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
- package/skills/cometchat-angular-components/SKILL.md +1 -1
- package/skills/cometchat-angular-core/SKILL.md +1 -1
- package/skills/cometchat-angular-customization/SKILL.md +1 -1
- package/skills/cometchat-angular-features/SKILL.md +1 -1
- package/skills/cometchat-angular-patterns/SKILL.md +1 -1
- package/skills/cometchat-angular-placement/SKILL.md +1 -1
- package/skills/cometchat-angular-production/SKILL.md +1 -1
- package/skills/cometchat-angular-push/SKILL.md +403 -0
- package/skills/cometchat-angular-testing/SKILL.md +333 -0
- package/skills/cometchat-angular-theming/SKILL.md +1 -1
- package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-astro-patterns/SKILL.md +1 -1
- package/skills/cometchat-calls/SKILL.md +358 -0
- package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
- package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
- package/skills/cometchat-calls/references/use-case-support.md +190 -0
- package/skills/cometchat-calls/references/use-case-team.md +169 -0
- package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
- package/skills/cometchat-components/SKILL.md +1 -1
- package/skills/cometchat-core/SKILL.md +1 -1
- package/skills/cometchat-customization/SKILL.md +2 -2
- package/skills/cometchat-features/SKILL.md +2 -2
- package/skills/cometchat-flutter-v5/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
- package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
- package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
- package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
- package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
- package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
- package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
- package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
- package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
- package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
- package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
- package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
- package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
- package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
- package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
- package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
- package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
- package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
- package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
- package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
- package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
- package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
- package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
- package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
- package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
- package/skills/cometchat-i18n/SKILL.md +358 -0
- package/skills/cometchat-ios/SKILL.md +5 -5
- package/skills/cometchat-ios-calls/SKILL.md +409 -0
- package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
- package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
- package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
- package/skills/cometchat-ios-calls/references/call-session.md +221 -0
- package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
- package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
- package/skills/cometchat-ios-calls/references/device-management.md +171 -0
- package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
- package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
- package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
- package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
- package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
- package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
- package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
- package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
- package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
- package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
- package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
- package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
- package/skills/cometchat-ios-components/SKILL.md +1 -1
- package/skills/cometchat-ios-core/SKILL.md +1 -1
- package/skills/cometchat-ios-customization/SKILL.md +1 -1
- package/skills/cometchat-ios-features/SKILL.md +1 -1
- package/skills/cometchat-ios-placement/SKILL.md +1 -1
- package/skills/cometchat-ios-production/SKILL.md +1 -1
- package/skills/cometchat-ios-push/SKILL.md +1 -1
- package/skills/cometchat-ios-testing/SKILL.md +371 -0
- package/skills/cometchat-ios-theming/SKILL.md +1 -1
- package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
- package/skills/cometchat-native-calls/SKILL.md +599 -0
- package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
- package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
- package/skills/cometchat-native-calls/references/call-session.md +182 -0
- package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
- package/skills/cometchat-native-calls/references/device-management.md +135 -0
- package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
- package/skills/cometchat-native-calls/references/group-calls.md +291 -0
- package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
- package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
- package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
- package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
- package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
- package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
- package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
- package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
- package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
- package/skills/cometchat-native-calls/references/share-invite.md +144 -0
- package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
- package/skills/cometchat-native-components/SKILL.md +1 -1
- package/skills/cometchat-native-core/SKILL.md +1 -1
- package/skills/cometchat-native-customization/SKILL.md +1 -1
- package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
- package/skills/cometchat-native-features/SKILL.md +1 -1
- package/skills/cometchat-native-placement/SKILL.md +1 -1
- package/skills/cometchat-native-production/SKILL.md +1 -1
- package/skills/cometchat-native-push/SKILL.md +1 -1
- package/skills/cometchat-native-testing/SKILL.md +1 -1
- package/skills/cometchat-native-theming/SKILL.md +1 -1
- package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
- package/skills/cometchat-placement/SKILL.md +29 -1
- package/skills/cometchat-production/SKILL.md +1 -1
- package/skills/cometchat-react-calls/SKILL.md +539 -0
- package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
- package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
- package/skills/cometchat-react-calls/references/call-session.md +235 -0
- package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
- package/skills/cometchat-react-calls/references/device-management.md +206 -0
- package/skills/cometchat-react-calls/references/group-calls.md +262 -0
- package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
- package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
- package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
- package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
- package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
- package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
- package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
- package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
- package/skills/cometchat-react-calls/references/share-invite.md +176 -0
- package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
- package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
- package/skills/cometchat-react-patterns/SKILL.md +56 -8
- package/skills/cometchat-react-push/SKILL.md +448 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
- package/skills/cometchat-react-testing/SKILL.md +404 -0
- package/skills/cometchat-theming/SKILL.md +3 -3
- package/skills/cometchat-troubleshooting/SKILL.md +2 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Call layouts on Angular
|
|
2
|
+
|
|
3
|
+
Same SDK API as web. Angular wraps layout state in a service so multiple components (toolbar, sidebar, header) can stay in sync.
|
|
4
|
+
|
|
5
|
+
**Canonical docs:** https://www.cometchat.com/docs/calls/javascript/call-layouts
|
|
6
|
+
**Read first:** `cometchat-react-calls/references/call-layouts.md` — layout matrix + when to lock.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Layout service
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { Injectable, NgZone } from "@angular/core";
|
|
14
|
+
import { BehaviorSubject } from "rxjs";
|
|
15
|
+
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
|
|
16
|
+
|
|
17
|
+
export type CallLayout = "TILE" | "SIDEBAR" | "SPOTLIGHT";
|
|
18
|
+
|
|
19
|
+
@Injectable({ providedIn: "root" })
|
|
20
|
+
export class CallLayoutService {
|
|
21
|
+
readonly layout$ = new BehaviorSubject<CallLayout>("TILE");
|
|
22
|
+
|
|
23
|
+
constructor(private zone: NgZone) {
|
|
24
|
+
CometChatCalls.addEventListener("onCallLayoutChanged", (next: string) => {
|
|
25
|
+
this.zone.run(() => this.layout$.next(next as CallLayout));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set(layout: CallLayout): void {
|
|
30
|
+
CometChatCalls.setLayout(layout);
|
|
31
|
+
this.layout$.next(layout);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Switcher component (mat-button-toggle-group)
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
@Component({
|
|
42
|
+
selector: "app-layout-switcher",
|
|
43
|
+
template: `
|
|
44
|
+
<mat-button-toggle-group
|
|
45
|
+
[value]="layout$ | async"
|
|
46
|
+
(change)="onChange($event.value)"
|
|
47
|
+
aria-label="Call layout"
|
|
48
|
+
>
|
|
49
|
+
<mat-button-toggle value="TILE" aria-label="Tile layout">Tile</mat-button-toggle>
|
|
50
|
+
<mat-button-toggle value="SIDEBAR" aria-label="Sidebar layout">Sidebar</mat-button-toggle>
|
|
51
|
+
<mat-button-toggle value="SPOTLIGHT" aria-label="Spotlight layout">Spotlight</mat-button-toggle>
|
|
52
|
+
</mat-button-toggle-group>
|
|
53
|
+
`,
|
|
54
|
+
})
|
|
55
|
+
export class LayoutSwitcherComponent {
|
|
56
|
+
layout$ = this.svc.layout$;
|
|
57
|
+
constructor(private svc: CallLayoutService) {}
|
|
58
|
+
onChange(layout: CallLayout) {
|
|
59
|
+
this.svc.set(layout);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`mat-button-toggle-group` already wires up `role="radiogroup"` semantics — no extra ARIA needed.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Pass initial via call settings
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const callSettings = new CallSettingsBuilder()
|
|
72
|
+
.setLayout("SPOTLIGHT")
|
|
73
|
+
.setHideChangeLayoutButton(true) // if you ship LayoutSwitcherComponent
|
|
74
|
+
.build();
|
|
75
|
+
|
|
76
|
+
await CometChatCalls.joinSession(callToken, callSettings, container.nativeElement);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Anti-patterns
|
|
82
|
+
|
|
83
|
+
Web sister rules apply, plus Angular-specific:
|
|
84
|
+
|
|
85
|
+
1. **No `NgZone.run` wrap on the SDK callback.** Layout changes via the kit's switcher don't update the toggle group in OnPush components.
|
|
86
|
+
2. **Service provided in a feature module instead of root.** Layout state resets when navigating away and back.
|
|
87
|
+
3. **`(click)` on each toggle setting layout individually.** `mat-button-toggle-group`'s `(change)` is the right hook — single source of truth.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Verification checklist
|
|
92
|
+
|
|
93
|
+
- [ ] `CallLayoutService` provided in root
|
|
94
|
+
- [ ] `NgZone.run` wraps the SDK callback
|
|
95
|
+
- [ ] `mat-button-toggle-group` `(change)` calls `svc.set`
|
|
96
|
+
- [ ] Initial layout via `CallSettingsBuilder.setLayout`
|
|
97
|
+
- [ ] Browser smoke: 3 tabs, each picks a different layout, no cross-talk
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Pointers
|
|
102
|
+
|
|
103
|
+
- `cometchat-react-calls/references/call-layouts.md` — sister
|
|
104
|
+
- `cometchat-angular-calls` SKILL.md
|
|
105
|
+
- `references/ngzone-and-async-callbacks.md`
|
|
106
|
+
- Canonical docs: https://www.cometchat.com/docs/calls/javascript/call-layouts
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Call session — joinSession with no ringing (Angular)
|
|
2
|
+
|
|
3
|
+
Same SDK API as web. This file mirrors the upstream Angular sample at `~/Downloads/calls-sdk/calls-sdk-javascript-5/sample-apps/cometchat-calls-sample-app-angular/src/app/pages/join-session/`. Customer-validated against the v5 SDK as the known-good shape.
|
|
4
|
+
|
|
5
|
+
**Read first:** `cometchat-react-calls/references/call-session.md` — full architecture (sessionId strategies, server-side authorization, token generation), then come back here for Angular specialization.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Hard rules (Angular-specific overrides on top of the React-side rules)
|
|
10
|
+
|
|
11
|
+
1. **Use a signal for `inMeeting` state, `@if` to render the container, `viewChild` to read it.** This is the upstream sample's exact shape and avoids stale-template traps under OnPush change detection.
|
|
12
|
+
2. **Container CSS:** `position: fixed; top: 0; left: 0; width: 100vw; height: 100vh`. Matches the sample. Flex-derived sizing inside nested route outlets has produced "iframe renders at 0×0 → no video" in customer integrations.
|
|
13
|
+
3. **Pass an empty `{}` settings object.** Explicit `{ sessionType: "VIDEO", layout: "TILE" }` is type-valid but the sample app uses `{}` — that's the empirically-validated combination.
|
|
14
|
+
4. **`onConnectionClosed`** is the cleanup event, not `onSessionLeft`. Fires on ANY termination (peer left, network died, in-iframe Leave button).
|
|
15
|
+
5. **NgZone.run around router navigation in the event listener.** SDK events fire outside Angular's zone; raw router calls won't trigger change detection.
|
|
16
|
+
6. **For standalone session-only integrations, the Chat SDK is OPTIONAL.** Use `CometChatCalls.init({appId, region, authKey})` + `CometChatCalls.login(uid)` alone. The upstream sample never imports `@cometchat/chat-sdk-javascript`. Keep dual-SDK only for additive (chat + calls) integrations.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Component (signals + @if + viewChild)
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import {
|
|
24
|
+
Component, OnInit, OnDestroy,
|
|
25
|
+
signal, viewChild, ElementRef, inject, NgZone,
|
|
26
|
+
} from '@angular/core';
|
|
27
|
+
import { Router, ActivatedRoute } from '@angular/router';
|
|
28
|
+
import { CometChatCalls } from '@cometchat/calls-sdk-javascript';
|
|
29
|
+
|
|
30
|
+
@Component({
|
|
31
|
+
selector: 'app-call-room',
|
|
32
|
+
standalone: true,
|
|
33
|
+
template: `
|
|
34
|
+
@if (inMeeting()) {
|
|
35
|
+
<div class="meeting-container" #meetingContainer></div>
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
styles: [`
|
|
39
|
+
.meeting-container {
|
|
40
|
+
position: fixed;
|
|
41
|
+
top: 0;
|
|
42
|
+
left: 0;
|
|
43
|
+
width: 100vw;
|
|
44
|
+
height: 100vh;
|
|
45
|
+
}
|
|
46
|
+
`],
|
|
47
|
+
})
|
|
48
|
+
export class CallRoomComponent implements OnInit, OnDestroy {
|
|
49
|
+
private route = inject(ActivatedRoute);
|
|
50
|
+
private router = inject(Router);
|
|
51
|
+
private zone = inject(NgZone);
|
|
52
|
+
|
|
53
|
+
sessionId = '';
|
|
54
|
+
inMeeting = signal(false);
|
|
55
|
+
|
|
56
|
+
// Signal-based viewChild — populated after the @if block renders.
|
|
57
|
+
meetingContainer = viewChild<ElementRef<HTMLDivElement>>('meetingContainer');
|
|
58
|
+
|
|
59
|
+
private cleanupEventListener?: () => void;
|
|
60
|
+
|
|
61
|
+
ngOnInit(): void {
|
|
62
|
+
this.sessionId = this.route.snapshot.paramMap.get('sessionId') ?? '';
|
|
63
|
+
|
|
64
|
+
// Cleanup listener fires on ANY session termination (peer left,
|
|
65
|
+
// network dropped, in-iframe Leave clicked). Reset state via NgZone
|
|
66
|
+
// so OnPush change detection picks it up.
|
|
67
|
+
this.cleanupEventListener = CometChatCalls.addEventListener(
|
|
68
|
+
'onConnectionClosed',
|
|
69
|
+
() => this.zone.run(() => {
|
|
70
|
+
this.inMeeting.set(false);
|
|
71
|
+
this.router.navigate(['/']);
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (this.sessionId) {
|
|
76
|
+
this.startMeeting();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ngOnDestroy(): void {
|
|
81
|
+
this.cleanupEventListener?.();
|
|
82
|
+
try {
|
|
83
|
+
CometChatCalls.leaveSession();
|
|
84
|
+
} catch {
|
|
85
|
+
// ignore — not joined or already left
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private startMeeting(): void {
|
|
90
|
+
this.inMeeting.set(true);
|
|
91
|
+
|
|
92
|
+
// setTimeout(0) gives Angular one tick to render the @if block
|
|
93
|
+
// so meetingContainer() is populated before joinSession measures it.
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
CometChatCalls.generateToken(this.sessionId).then(({ token }) => {
|
|
96
|
+
const container = this.meetingContainer();
|
|
97
|
+
if (container) {
|
|
98
|
+
// Empty {} settings = SDK defaults (matches sample app).
|
|
99
|
+
CometChatCalls.joinSession(token, {}, container.nativeElement);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}, 0);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Why this shape (not the obvious alternatives):**
|
|
108
|
+
|
|
109
|
+
- **`@if (inMeeting())` + `viewChild`** instead of always-rendered container + `@ViewChild({ static: true })` — matches the upstream sample. The signal-based pattern works under OnPush change detection without `markForCheck()` ceremonies.
|
|
110
|
+
- **`position: fixed; 100vw × 100vh`** instead of `width: 100%; height: 100vh` — gives the SDK a deterministic viewport-anchored container. Flex-derived sizing inside route outlets has caused 0×0 iframe rendering.
|
|
111
|
+
- **Empty `{}` settings** — the sample's validated combination. Explicit `{ sessionType: "VIDEO", layout: "TILE" }` is type-valid but has produced unexplained rendering issues.
|
|
112
|
+
- **`onConnectionClosed`** — fires on ANY termination, not just user-initiated leave. More reliable for cleanup than `onSessionLeft`.
|
|
113
|
+
- **`setTimeout(0)` after `inMeeting.set(true)`** — gives Angular one change-detection tick to render the `@if` block, so `meetingContainer()` is populated when `joinSession` measures it. The upstream sample uses the same trick (see `startInstantMeeting`).
|
|
114
|
+
- **`NgZone.run` around router navigation in the listener** — SDK events fire outside Angular's zone; raw `router.navigate` won't trigger change detection. UI freezes despite URL changing.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Route configuration
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const routes: Routes = [
|
|
122
|
+
{ path: 'meet/:sessionId', component: CallRoomComponent, data: { reuseRoute: false } },
|
|
123
|
+
];
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Read `sessionId` via `ActivatedRoute.snapshot.paramMap.get('sessionId')` in `ngOnInit`.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Anti-patterns
|
|
131
|
+
|
|
132
|
+
1. **Always-rendered container with `@ViewChild({ static: true })`.** Works but doesn't match the sample app pattern and forces you to handle "not yet joined" rendering inside the SDK's iframe area. Use `@if` + `viewChild` signal instead.
|
|
133
|
+
2. **`@ViewChild({ static: false })` without compensating logic.** Container ref is undefined in `ngOnInit` — `joinSession` throws or no-ops.
|
|
134
|
+
3. **`width: 100%; height: 100vh` container.** Works in flat layouts; fails in nested route outlets or flex parents. Use `position: fixed` instead.
|
|
135
|
+
4. **Explicit `{ sessionType, layout, ... }` settings.** Type-valid but has caused unexplained black-tile-on-local-preview behaviour in customer integrations. Use `{}` and let the SDK pick defaults.
|
|
136
|
+
5. **`onSessionLeft` only.** Fires on graceful user leave but NOT on network drops or peer disconnects. Use `onConnectionClosed` for the cleanup path.
|
|
137
|
+
6. **Calling `startMeeting()` synchronously after `inMeeting.set(true)`.** The `@if` block hasn't rendered yet — `meetingContainer()` returns undefined. Wrap the `generateToken` + `joinSession` call in `setTimeout(0)` (or `afterNextRender` in Angular 16+).
|
|
138
|
+
7. **No `NgZone.run` around router navigation in event listeners.** SDK fires outside Angular's zone — change detection doesn't run, UI freezes.
|
|
139
|
+
8. **Component reused via `RouteReuseStrategy`.** Stale signal state → second navigation skips `joinSession`. Disable reuse for the call route.
|
|
140
|
+
9. **Initializing Chat SDK for a session-only integration.** Wastes time and adds two extra failure modes (Chat init, Chat login race). Drop `CometChat.init` / `CometChat.login` entirely for standalone session apps.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Verification checklist
|
|
145
|
+
|
|
146
|
+
- [ ] Container uses `position: fixed; width: 100vw; height: 100vh` (sample-app pattern)
|
|
147
|
+
- [ ] Container rendered via `@if (inMeeting())`, read via `viewChild`
|
|
148
|
+
- [ ] Settings passed as empty `{}`, not explicit `{ sessionType, layout, ... }`
|
|
149
|
+
- [ ] `onConnectionClosed` listener handles session end (not just `onSessionLeft`)
|
|
150
|
+
- [ ] `NgZone.run` wraps router navigation in the event handler
|
|
151
|
+
- [ ] `setTimeout(0)` (or `afterNextRender`) gates `joinSession` until the `@if` block renders
|
|
152
|
+
- [ ] `leaveSession` called in `ngOnDestroy`
|
|
153
|
+
- [ ] Listener cleanup function called in `ngOnDestroy`
|
|
154
|
+
- [ ] Route has `data: { reuseRoute: false }` to prevent stale-component reuse
|
|
155
|
+
- [ ] **Standalone session-only:** no `CometChat.init` / `CometChat.login` — Calls SDK alone
|
|
156
|
+
- [ ] **Additive (chat + calls):** dual-SDK contract preserved (Chat first, then Calls)
|
|
157
|
+
- [ ] Browser smoke: 2 tabs, both navigate to `/meet/${sessionId}`, both join, media flows, either leaves → other sees onConnectionClosed
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Pointers
|
|
162
|
+
|
|
163
|
+
- `cometchat-react-calls/references/call-session.md` — full architecture (sessionId strategies, server-side authorization)
|
|
164
|
+
- `cometchat-angular-calls/SKILL.md` — Angular-specific dual-SDK init pattern
|
|
165
|
+
- `references/ngzone-and-async-callbacks.md` — why NgZone.run matters for SDK events
|
|
166
|
+
- Upstream Angular sample — `~/Downloads/calls-sdk/calls-sdk-javascript-5/sample-apps/cometchat-calls-sample-app-angular/src/app/pages/join-session/`
|
|
167
|
+
- Canonical docs: https://www.cometchat.com/docs/calls/javascript/join-session
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Custom call UI in Angular
|
|
2
|
+
|
|
3
|
+
Same architecture as React + RN custom UI; Angular-specific because of NgZone, ContentChild, and ng-template.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Two paths
|
|
8
|
+
|
|
9
|
+
1. **Style the kit's selectors** — pass Angular `[input]` props + content projection (`<ng-content select="...">`). Cheapest.
|
|
10
|
+
2. **Build your own component on the SDK** — direct `CometChatCalls.joinSession(token, settings, container)` with your own `<video>` elements wrapped in Angular components. (`startSession` is a deprecated v4 shim — use `joinSession`.)
|
|
11
|
+
|
|
12
|
+
This reference covers path 2.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Component skeleton
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// ongoing-call.component.ts
|
|
20
|
+
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
|
21
|
+
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
|
|
22
|
+
|
|
23
|
+
@Component({
|
|
24
|
+
selector: "app-ongoing-call",
|
|
25
|
+
template: `
|
|
26
|
+
<div class="call-container">
|
|
27
|
+
<video #remoteVideo autoplay playsinline class="remote-tile"></video>
|
|
28
|
+
<video #localVideo autoplay playsinline muted class="local-tile"></video>
|
|
29
|
+
<app-control-panel
|
|
30
|
+
[muted]="muted"
|
|
31
|
+
[cameraOff]="cameraOff"
|
|
32
|
+
(toggleMute)="onToggleMute()"
|
|
33
|
+
(toggleCamera)="onToggleCamera()"
|
|
34
|
+
(switchCamera)="onSwitchCamera()"
|
|
35
|
+
(end)="onEnd()"
|
|
36
|
+
></app-control-panel>
|
|
37
|
+
</div>
|
|
38
|
+
`,
|
|
39
|
+
styles: [`
|
|
40
|
+
.call-container { position: fixed; inset: 0; background: #000; }
|
|
41
|
+
.remote-tile { width: 100%; height: 100%; object-fit: cover; }
|
|
42
|
+
.local-tile { position: absolute; top: 60px; right: 20px; width: 120px; height: 160px; border-radius: 8px; }
|
|
43
|
+
`],
|
|
44
|
+
})
|
|
45
|
+
export class OngoingCallComponent implements OnInit, OnDestroy {
|
|
46
|
+
@ViewChild("localVideo") localVideoRef!: ElementRef<HTMLVideoElement>;
|
|
47
|
+
@ViewChild("remoteVideo") remoteVideoRef!: ElementRef<HTMLVideoElement>;
|
|
48
|
+
|
|
49
|
+
muted = false;
|
|
50
|
+
cameraOff = false;
|
|
51
|
+
|
|
52
|
+
private listener: unknown;
|
|
53
|
+
|
|
54
|
+
constructor(private zone: NgZone) {}
|
|
55
|
+
|
|
56
|
+
async ngOnInit() {
|
|
57
|
+
this.listener = new CometChatCalls.OngoingCallListener({
|
|
58
|
+
onUserListUpdated: (users: unknown) => {
|
|
59
|
+
this.zone.run(() => { /* update roster */ });
|
|
60
|
+
},
|
|
61
|
+
onCallEnded: () => {
|
|
62
|
+
this.zone.run(() => this.cleanup());
|
|
63
|
+
},
|
|
64
|
+
onCallEndButtonPressed: () => CometChatCalls.leaveSession(),
|
|
65
|
+
onError: (err: unknown) => {
|
|
66
|
+
this.zone.run(() => console.error("Call error:", err));
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const settings = new CometChatCalls.CallSettingsBuilder()
|
|
71
|
+
.setSessionID(this.sessionId)
|
|
72
|
+
.setIsAudioOnly(false)
|
|
73
|
+
.enableDefaultLayout(false)
|
|
74
|
+
.setCallEventListener(this.listener)
|
|
75
|
+
.build();
|
|
76
|
+
|
|
77
|
+
// v5 — generateToken takes ONLY sessionId. Auth is internal after CometChatCalls.login().
|
|
78
|
+
const tokenRes = await CometChatCalls.generateToken(this.sessionId);
|
|
79
|
+
// htmlElement is required — pass the call container ref.
|
|
80
|
+
// joinSession is the v5 canonical — startSession is a deprecated shim.
|
|
81
|
+
CometChatCalls.joinSession(tokenRes.token, settings, this.callContainerRef.nativeElement);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
ngOnDestroy() {
|
|
85
|
+
this.cleanup();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
onToggleMute() {
|
|
89
|
+
this.muted = !this.muted;
|
|
90
|
+
CometChatCalls.muteAudio(this.muted);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
onToggleCamera() {
|
|
94
|
+
this.cameraOff = !this.cameraOff;
|
|
95
|
+
CometChatCalls.pauseVideo(this.cameraOff);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onSwitchCamera() {
|
|
99
|
+
CometChatCalls.switchCamera();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
onEnd() {
|
|
103
|
+
CometChatCalls.leaveSession();
|
|
104
|
+
this.cleanup();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private cleanup() {
|
|
108
|
+
CometChatCalls.leaveSession();
|
|
109
|
+
if (this.localVideoRef?.nativeElement) this.localVideoRef.nativeElement.srcObject = null;
|
|
110
|
+
if (this.remoteVideoRef?.nativeElement) this.remoteVideoRef.nativeElement.srcObject = null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Inputs
|
|
114
|
+
sessionId!: string; // bind from route param or parent
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
NgZone.run wraps every SDK callback that mutates `this.*` (rule from `references/ngzone-and-async-callbacks.md`).
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Control panel as a child component
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
// control-panel.component.ts
|
|
126
|
+
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
|
127
|
+
|
|
128
|
+
@Component({
|
|
129
|
+
selector: "app-control-panel",
|
|
130
|
+
template: `
|
|
131
|
+
<div class="row">
|
|
132
|
+
<button (click)="toggleMute.emit()">{{ muted ? "Unmute" : "Mute" }}</button>
|
|
133
|
+
<button (click)="toggleCamera.emit()">{{ cameraOff ? "Cam on" : "Cam off" }}</button>
|
|
134
|
+
<button (click)="switchCamera.emit()">Flip</button>
|
|
135
|
+
<button (click)="end.emit()" class="end">End</button>
|
|
136
|
+
</div>
|
|
137
|
+
`,
|
|
138
|
+
styles: [`
|
|
139
|
+
.row { position: absolute; bottom: 40px; left: 0; right: 0; display: flex; justify-content: space-around; }
|
|
140
|
+
button { padding: 16px; border-radius: 32px; }
|
|
141
|
+
.end { background: red; color: white; }
|
|
142
|
+
`],
|
|
143
|
+
})
|
|
144
|
+
export class ControlPanelComponent {
|
|
145
|
+
@Input() muted = false;
|
|
146
|
+
@Input() cameraOff = false;
|
|
147
|
+
@Output() toggleMute = new EventEmitter<void>();
|
|
148
|
+
@Output() toggleCamera = new EventEmitter<void>();
|
|
149
|
+
@Output() switchCamera = new EventEmitter<void>();
|
|
150
|
+
@Output() end = new EventEmitter<void>();
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Local preview before the call connects
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
async ngOnInit() {
|
|
160
|
+
// ... listener setup ...
|
|
161
|
+
|
|
162
|
+
// Preview stream
|
|
163
|
+
try {
|
|
164
|
+
const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
|
|
165
|
+
this.localStream = stream;
|
|
166
|
+
if (this.localVideoRef.nativeElement) {
|
|
167
|
+
this.localVideoRef.nativeElement.srcObject = stream;
|
|
168
|
+
}
|
|
169
|
+
} catch (err) {
|
|
170
|
+
if ((err as Error).name === "NotAllowedError") {
|
|
171
|
+
this.zone.run(() => this.errorMessage = "Camera/mic permission denied");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Then start session — SDK takes over
|
|
176
|
+
// ...
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
ngOnDestroy() {
|
|
180
|
+
this.localStream?.getTracks().forEach(t => t.stop()); // CRITICAL — release tracks
|
|
181
|
+
this.cleanup();
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Lazy loading custom call modules
|
|
188
|
+
|
|
189
|
+
If your project lazy-loads the calls feature (a `CallsModule` lazy-loaded at `/calls`), there's a gotcha:
|
|
190
|
+
|
|
191
|
+
The `cometchat-angular-core` skill says `APP_INITIALIZER` must run at bootstrap, before lazy-loaded routes. If your `CallInitService` is provided in `CallsModule` (lazy), `APP_INITIALIZER` can't depend on it — Angular hasn't loaded the module yet.
|
|
192
|
+
|
|
193
|
+
**Fix:** provide `CallInitService` in `AppModule` (eager), even if call components live in a lazy module. The service runs at boot; the components load on demand. This is documented further in `references/lazy-loading-pitfalls.md`.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Route guard for active calls
|
|
198
|
+
|
|
199
|
+
If the user navigates away from the ongoing-call component mid-call, the call should end:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
// can-deactivate.guard.ts
|
|
203
|
+
import { Injectable } from "@angular/core";
|
|
204
|
+
import { CanDeactivate } from "@angular/router";
|
|
205
|
+
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
|
|
206
|
+
import { OngoingCallComponent } from "./ongoing-call.component";
|
|
207
|
+
|
|
208
|
+
@Injectable({ providedIn: "root" })
|
|
209
|
+
export class CallDeactivateGuard implements CanDeactivate<OngoingCallComponent> {
|
|
210
|
+
canDeactivate(component: OngoingCallComponent): boolean {
|
|
211
|
+
if (!component.callActive) return true;
|
|
212
|
+
const confirmed = window.confirm("End the active call?");
|
|
213
|
+
if (confirmed) {
|
|
214
|
+
CometChatCalls.leaveSession();
|
|
215
|
+
}
|
|
216
|
+
return confirmed;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Register on the route:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
{ path: "calls/ongoing/:id", component: OngoingCallComponent, canDeactivate: [CallDeactivateGuard] }
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## When NOT to go custom in Angular
|
|
230
|
+
|
|
231
|
+
Same as React/RN — kit defaults cover 80%+. NgZone wrangling is real overhead; prefer styling props on `<cometchat-ongoing-call>` first. Custom is for design-system requirements that the kit's CSS variable overrides can't reach.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Device management on Angular
|
|
2
|
+
|
|
3
|
+
Same JS SDK as web. Angular wraps device-list state in a service with RxJS observables.
|
|
4
|
+
|
|
5
|
+
**Canonical docs:** https://www.cometchat.com/docs/calls/javascript/device-management
|
|
6
|
+
**Read first:** `cometchat-react-calls/references/device-management.md` — pre-call picker + empty-label gotcha.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Service-driven device lists
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { Injectable, NgZone } from "@angular/core";
|
|
14
|
+
import { BehaviorSubject } from "rxjs";
|
|
15
|
+
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
|
|
16
|
+
|
|
17
|
+
interface MediaDevice { id: string; label: string; }
|
|
18
|
+
|
|
19
|
+
@Injectable({ providedIn: "root" })
|
|
20
|
+
export class CallDevicesService {
|
|
21
|
+
readonly mics$ = new BehaviorSubject<MediaDevice[]>([]);
|
|
22
|
+
readonly cameras$ = new BehaviorSubject<MediaDevice[]>([]);
|
|
23
|
+
readonly speakers$ = new BehaviorSubject<MediaDevice[]>([]);
|
|
24
|
+
|
|
25
|
+
constructor(private zone: NgZone) {
|
|
26
|
+
CometChatCalls.addEventListener("onAudioModesUpdated", () => {
|
|
27
|
+
this.zone.run(() => this.refresh());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async ensurePermission(): Promise<void> {
|
|
32
|
+
try {
|
|
33
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
|
|
34
|
+
stream.getTracks().forEach(t => t.stop()); // immediately release; we just wanted permission
|
|
35
|
+
} catch {
|
|
36
|
+
// permission denied
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async refresh(): Promise<void> {
|
|
41
|
+
const [mics, cameras, speakers] = await Promise.all([
|
|
42
|
+
CometChatCalls.getAudioInputDevices(),
|
|
43
|
+
CometChatCalls.getVideoInputDevices(),
|
|
44
|
+
CometChatCalls.getAudioOutputDevices(),
|
|
45
|
+
]);
|
|
46
|
+
this.mics$.next(mics);
|
|
47
|
+
this.cameras$.next(cameras);
|
|
48
|
+
this.speakers$.next(speakers);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async selectMic(id: string): Promise<void> {
|
|
52
|
+
await CometChatCalls.setAudioInputDevice(id);
|
|
53
|
+
}
|
|
54
|
+
async selectCamera(id: string): Promise<void> {
|
|
55
|
+
await CometChatCalls.setVideoInputDevice(id);
|
|
56
|
+
}
|
|
57
|
+
async selectSpeaker(id: string): Promise<void> {
|
|
58
|
+
await CometChatCalls.setAudioOutputDevice(id);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Picker component
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
@Component({
|
|
69
|
+
selector: "app-device-picker",
|
|
70
|
+
template: `
|
|
71
|
+
<form (ngSubmit)="confirm()">
|
|
72
|
+
<label>Microphone
|
|
73
|
+
<select [(ngModel)]="selectedMic" name="mic">
|
|
74
|
+
<option *ngFor="let d of mics$ | async" [value]="d.id">
|
|
75
|
+
{{ d.label || ('Mic ' + d.id.substring(0, 6)) }}
|
|
76
|
+
</option>
|
|
77
|
+
</select>
|
|
78
|
+
</label>
|
|
79
|
+
<!-- camera + speaker selects same pattern -->
|
|
80
|
+
<button type="submit">Join call</button>
|
|
81
|
+
</form>
|
|
82
|
+
`,
|
|
83
|
+
})
|
|
84
|
+
export class DevicePickerComponent implements OnInit {
|
|
85
|
+
mics$ = this.devices.mics$;
|
|
86
|
+
cameras$ = this.devices.cameras$;
|
|
87
|
+
speakers$ = this.devices.speakers$;
|
|
88
|
+
selectedMic = "";
|
|
89
|
+
selectedCamera = "";
|
|
90
|
+
selectedSpeaker = "";
|
|
91
|
+
|
|
92
|
+
constructor(private devices: CallDevicesService) {}
|
|
93
|
+
|
|
94
|
+
async ngOnInit() {
|
|
95
|
+
await this.devices.ensurePermission();
|
|
96
|
+
await this.devices.refresh();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async confirm() {
|
|
100
|
+
if (this.selectedMic) await this.devices.selectMic(this.selectedMic);
|
|
101
|
+
if (this.selectedCamera) await this.devices.selectCamera(this.selectedCamera);
|
|
102
|
+
if (this.selectedSpeaker) await this.devices.selectSpeaker(this.selectedSpeaker);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Anti-patterns
|
|
110
|
+
|
|
111
|
+
Web sister rules apply, plus Angular-specific:
|
|
112
|
+
|
|
113
|
+
1. **No `NgZone.run` wrap on `onAudioModesUpdated`.** BehaviorSubject emits but UI doesn't update with OnPush.
|
|
114
|
+
2. **Service NOT provided in `root`.** Lazy-loaded → device events miss.
|
|
115
|
+
3. **`async pipe` not used.** Manual `subscribe` without `unsubscribe` leaks.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Verification checklist
|
|
120
|
+
|
|
121
|
+
- [ ] `CallDevicesService` provided in root
|
|
122
|
+
- [ ] `NgZone.run` wraps the device-update event
|
|
123
|
+
- [ ] Picker uses `async` pipe (not manual subscribe)
|
|
124
|
+
- [ ] `ensurePermission()` called before `refresh()` (empty-label fix)
|
|
125
|
+
- [ ] Browser smoke: plug/unplug headphones during call → list updates
|
|
126
|
+
- [ ] Safari smoke: speaker picker hidden (Safari limitation)
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Pointers
|
|
131
|
+
|
|
132
|
+
- `cometchat-react-calls/references/device-management.md` — sister web reference
|
|
133
|
+
- `cometchat-angular-calls` SKILL.md
|
|
134
|
+
- `references/ngzone-and-async-callbacks.md` — NgZone primer
|
|
135
|
+
- Canonical docs: https://www.cometchat.com/docs/calls/javascript/device-management
|