in packages/calling-stateful-client/src/CallDeclarativeCommon.ts [32:131]
public get<P extends keyof CallCommon>(target: CallCommon, prop: P): any {
switch (prop) {
case 'mute': {
return this._context.withAsyncErrorTeedToState(async function (...args: Parameters<CallCommon['mute']>) {
return await target.mute(...args);
}, 'Call.mute');
}
case 'unmute': {
return this._context.withAsyncErrorTeedToState(async function (...args: Parameters<CallCommon['unmute']>) {
return await target.unmute(...args);
}, 'Call.unmute');
}
case 'startVideo': {
return this._context.withAsyncErrorTeedToState(async function (...args: Parameters<CallCommon['startVideo']>) {
return await target.startVideo(...args);
}, 'Call.startVideo');
}
case 'stopVideo': {
return this._context.withAsyncErrorTeedToState(async function (...args: Parameters<CallCommon['stopVideo']>) {
return await target.stopVideo(...args);
}, 'Call.stopVideo');
}
case 'startScreenSharing': {
return this._context.withAsyncErrorTeedToState(async function (
...args: Parameters<CallCommon['startScreenSharing']>
) {
return await target.startScreenSharing(...args);
}, 'Call.startScreenSharing');
}
case 'stopScreenSharing': {
return this._context.withAsyncErrorTeedToState(async function (
...args: Parameters<CallCommon['stopScreenSharing']>
) {
return await target.stopScreenSharing(...args);
}, 'Call.stopScreenSharing');
}
case 'hold': {
return this._context.withAsyncErrorTeedToState(async function (...args: Parameters<CallCommon['hold']>) {
return await target.hold(...args);
}, 'Call.hold');
}
case 'resume': {
return this._context.withAsyncErrorTeedToState(async function (...args: Parameters<CallCommon['resume']>) {
return await target.resume(...args);
}, 'Call.resume');
}
case 'feature': {
// these are mini version of Proxy object - if it grows too big, a real Proxy object should be used.
return this._context.withErrorTeedToState((...args: Parameters<CallCommon['feature']>) => {
if (args[0] === Features.Captions) {
const captionsFeature = target.feature(Features.Captions);
let proxyFeature;
if (captionsFeature.captions.kind === 'Captions') {
proxyFeature = new ProxyCaptions(this._context, target);
return {
captions: new Proxy(captionsFeature.captions, proxyFeature),
on: (...args: Parameters<CaptionsCallFeature['on']>): void => {
const isCaptionsKindChanged = args[0] === 'CaptionsKindChanged';
if (isCaptionsKindChanged) {
const listener = args[1] as PropertyChangedEvent;
const newListener = (): void => {
listener();
};
return captionsFeature.on('CaptionsKindChanged', newListener);
}
},
off: (...args: Parameters<CaptionsCallFeature['off']>): void => {
const isCaptionsKindChanged = args[0] === 'CaptionsKindChanged';
if (isCaptionsKindChanged) {
return captionsFeature.off('CaptionsKindChanged', args[1]);
}
}
};
}
proxyFeature = new ProxyTeamsCaptions(this._context, target);
return {
captions: new Proxy(captionsFeature.captions, proxyFeature)
};
}
if (args[0] === Features.Transfer) {
const transferFeature = target.feature(Features.Transfer);
const proxyFeature = new ProxyTransferCallFeature(this._context, target);
return new Proxy(transferFeature, proxyFeature);
}
if (args[0] === Features.Spotlight) {
const spotlightFeature = target.feature(Features.Spotlight);
const proxyFeature = new ProxySpotlightCallFeature(this._context);
return new Proxy(spotlightFeature, proxyFeature);
}
if (args[0] === Features.RealTimeText && this._context.getState().userId.kind === 'microsoftTeamsUser') {
return;
}
return target.feature(...args);
}, 'Call.feature');
}
default:
return Reflect.get(target, prop);
}
}