-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathCapabilitiesSubscriber.ts
More file actions
39 lines (32 loc) · 1.26 KB
/
CapabilitiesSubscriber.ts
File metadata and controls
39 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/* @conditional-compile-remove(capabilities) */
import { CapabilitiesChangeInfo, CapabilitiesFeature } from '@azure/communication-calling';
/* @conditional-compile-remove(capabilities) */
import { CallContext } from './CallContext';
/* @conditional-compile-remove(capabilities) */
import { CallIdRef } from './CallIdRef';
/* @conditional-compile-remove(capabilities) */
/**
* @private
*/
export class CapabilitiesSubscriber {
private _callIdRef: CallIdRef;
private _context: CallContext;
private _capabilitiesFeature: CapabilitiesFeature;
constructor(callIdRef: CallIdRef, context: CallContext, capabilities: CapabilitiesFeature) {
this._callIdRef = callIdRef;
this._context = context;
this._capabilitiesFeature = capabilities;
this.subscribe();
}
private subscribe = (): void => {
this._capabilitiesFeature.on('capabilitiesChanged', this.capabilitiesChanged);
};
public unsubscribe = (): void => {
this._capabilitiesFeature.off('capabilitiesChanged', this.capabilitiesChanged);
};
private capabilitiesChanged = (data: CapabilitiesChangeInfo): void => {
this._context.setCapabilities(this._callIdRef.callId, this._capabilitiesFeature.capabilities, data);
};
}