StatefulCallClient interface
定義可讓 CallClient <xref:%40azure%2Fcommunication-calling%23CallClient> 具狀態使用的方法。 介面提供對 Proxy 狀態的存取權,也允許註冊狀態變更事件的處理程式。 如需狀態定義,請參閱 CallClientState。
狀態變更事件是由:
- 從 <xref:%40azure%2Fcommunication-calling%23DeviceManager> API 傳回的數據。
- 從 <xref:%40azure%2Fcommunication-calling%23CallAgent> API 傳回的數據。
- 自動附加至各種 Azure 通訊呼叫物件的接聽程式:
- CallAgent 'incomingCall'
- CallAgent 'callsUpdated'
- DeviceManager 'videoDevicesUpdated'
- DeviceManager 'audioDevicesUpdated
- DeviceManager 'selectedMicrophoneChanged'
- DeviceManager 'selectedSpeakerChanged'
- 呼叫 'stateChanged'
- 呼叫 'idChanged'
- 呼叫 'isMutedChanged'
- 呼叫 'isScreenSharingOnChanged'
- 呼叫 'remoteParticipantsUpdated'
- 呼叫 'localVideoStreamsUpdated'
- IncomingCall 'callEnded'
- RemoteParticipant 'stateChanged'
- RemoteParticipant 'isMutedChanged'
- RemoteParticipant 'displayNameChanged'
- 遠端參與者 'isSpeakingChanged'
- RemoteParticipant 'videoStreamsUpdated'
- RemoteVideoStream 'isAvailableChanged'
- TranscriptionCallFeature 'isTranscriptionActiveChanged'
- RecordingCallFeature 'isRecordingActiveChanged'
- LocalRecordingCallFeature 'isLocalRecordingActiveChanged'
- RaiseHandCallFeature 'raisedHandEvent'
- RaiseHandCallFeature 'loweredHandEvent'
- PPTLiveCallFeature 'isAciveChanged'
- ReactionCallFeature '反應'
- Extends
方法
| create |
CallAgent 可用來處理呼叫。 若要創建 CallAgent,請傳遞 SDK 提供的 CommunicationTokenCredential 物件。
|
| create |
TeamsCallAgent 用於處理呼叫。 若要創建TeamsCallAgent,請傳遞SDK提供的 CommunicationTokenCredential 物件。
|
| create |
渲染 RemoteVideoStreamState 或 LocalVideoStreamState ,並將生成的 VideoStreamRendererViewState 儲存在相關的 RemoteVideoStreamState 或 LocalVideoStreamState 下,或作為該狀態中的無父視圖存儲。 在後台呼叫 <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.createView>. 場景 1:渲染 RemoteVideoStreamState
場景 2:為通話呈現 LocalVideoStreamState
|
| dispose |
停止渲染 RemoteVideoStreamState 或 LocalVideoStreamState,並從 <xref:VideoStreamRendererView> 或 CallClientState 中的相關 <xref:LocalVideoStream> 中刪除 ,或者刪除相應的<xref:CallClientState.deviceManager.unparentedViews>後台調用<xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.dispose>。 disposeView 正確清理資源非常重要。 場景 1:釋放 RemoteVideoStreamState
場景 2:釋放通話的 LocalVideoStreamState
|
| get |
保存我們可以從 CallClient <xref:%40azure%2Fcommunication-calling%23CallClient> 代理為 CallClientState CallClientState 的所有狀態。 |
| off |
允許取消註冊 『stateChanged』 事件。 |
| on |
允許針對 『stateChanged』 事件註冊處理程式。 |
繼承的方法
| dispose() | 釋放此 CallClient,該 CallClient 也會釋放關聯的 設備管理員 和關聯的呼叫代理。 |
| feature<TFeature>(Call |
擷取具有擴充 API 的初始化和備忘功能物件。 檢查物件 Features.* 以取得此套件中所有可用的擴展呼叫用戶端功能。 |
| get |
DeviceManager 用於處理媒體設備,例如相機、麥克風和揚聲器。 |
方法詳細資料
createCallAgent([tokenCredential, options])
CallAgent 可用來處理呼叫。 若要創建 CallAgent,請傳遞 SDK 提供的 CommunicationTokenCredential 物件。
- CallClient 一次只能有一個活動的 CallAgent 實例。
- 您可以創建新的 CallClient 實例來創建新的 CallAgent。
- 您可以處理 CallClient 的當前活動 CallAgent,然後再次調用 CallClient 的 createCallAgent() 方法來創建新的 CallAgent。
function createCallAgent(args: [tokenCredential, options]): Promise<DeclarativeCallAgent>
參數
- args
-
[tokenCredential, options]
傳回
Promise<DeclarativeCallAgent>
createTeamsCallAgent([tokenCredential, options])
TeamsCallAgent 用於處理呼叫。 若要創建TeamsCallAgent,請傳遞SDK提供的 CommunicationTokenCredential 物件。
- CallClient 一次只能有一個活動的 TeamsCallAgent 實例。
- 您可以創建新的 CallClient 實例來創建新的 TeamsCallAgent。
- 您可以處理 CallClient 的當前活動 TeamsCallAgent,然後再次調用 CallClient 的 createTeamsCallAgent() 方法以創建新的 TeamsCallAgent。
function createTeamsCallAgent(args: [tokenCredential, options]): Promise<DeclarativeTeamsCallAgent>
參數
- args
-
[tokenCredential, options]
傳回
Promise<DeclarativeTeamsCallAgent>
createView(undefined | string, undefined | CommunicationIdentifier, CallFeatureStreamState | RemoteVideoStreamState | LocalVideoStreamState, CreateViewOptions)
渲染 RemoteVideoStreamState 或 LocalVideoStreamState ,並將生成的 VideoStreamRendererViewState 儲存在相關的 RemoteVideoStreamState 或 LocalVideoStreamState 下,或作為該狀態中的無父視圖存儲。 在後台呼叫 <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.createView>.
場景 1:渲染 RemoteVideoStreamState
- 需要 CallId,需要 participantId,並且需要 RemoteVideoStreamState 類型的 stream
- 生成的 VideoStreamRendererViewState 儲存在給定的 callId 中,並在 CallClientState 中存儲 participantId
場景 2:為通話呈現 LocalVideoStreamState
CallId 為必填項,participantId 為 undefined,且 LocalVideoStreamState 類型的流為必填項。
<xref:%40azure%2Fcommunication-calling%23Call.localVideoStreams>必須已開始使用 <xref:%40azure%2Fcommunication-calling%23Call.startVideo>。
生成的 VideoStreamRendererViewState 儲存在給定的 callId localVideoStreams 中的 CallClientState 中。
場景 2:渲染 LocalVideoStreamState 不是調用的一部分(用於本地預覽的渲染相機範例)
CallId 必須為 undefined,participantId 必須為 undefined,並且需要 LocalVideoStreamState 類型的 stream。
生成的 VideoStreamRendererViewState 儲存在給定的 LocalVideoStreamState 下 <xref:CallClientState.deviceManager.unparentedViews>
function createView(callId: undefined | string, participantId: undefined | CommunicationIdentifier, stream: CallFeatureStreamState | RemoteVideoStreamState | LocalVideoStreamState, options?: CreateViewOptions): Promise<undefined | CreateViewResult>
參數
- callId
-
undefined | string
CallId 的調用。 如果流不是任何調用的一部分,則可以 undefined。
- participantId
-
undefined | CommunicationIdentifier
<xref:RemoteParticipant.identifier> 與給定的 RemoteVideoStreamState 相關聯。 如果渲染 LocalVideoStreamState,則可能為 undefined。
LocalVideoStreamState 或 RemoteVideoStreamState 開始渲染。
- options
- CreateViewOptions
傳遞給 <xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer>.
傳回
Promise<undefined | CreateViewResult>
disposeView(undefined | string, undefined | CommunicationIdentifier, CallFeatureStreamState | RemoteVideoStreamState | LocalVideoStreamState)
停止渲染 RemoteVideoStreamState 或 LocalVideoStreamState,並從 <xref:VideoStreamRendererView> 或 CallClientState 中的相關 <xref:LocalVideoStream> 中刪除 ,或者刪除相應的<xref:CallClientState.deviceManager.unparentedViews>後台調用<xref:%40azure%2Fcommunication-calling%23VideoStreamRenderer.dispose>。
disposeView 正確清理資源非常重要。
場景 1:釋放 RemoteVideoStreamState
- 需要 CallId,需要 participantId,並且需要 RemoteVideoStreamState 類型的 stream
場景 2:釋放通話的 LocalVideoStreamState
CallId 為必填項,participantId 為 undefined,且 LocalVideoStreamState 類型的流為必填項。
場景 2:釋放不屬於調用的 LocalVideoStreamState
CallId 必須為 undefined,participantId 必須為 undefined,並且需要 LocalVideoStreamState 類型的 stream。
LocalVideoStreamState 必須是傳遞給 createView 的原始數據。
function disposeView(callId: undefined | string, participantId: undefined | CommunicationIdentifier, stream: CallFeatureStreamState | RemoteVideoStreamState | LocalVideoStreamState)
參數
- callId
-
undefined | string
CallId 的調用。 如果流不是任何調用的一部分,則可以 undefined。
- participantId
-
undefined | CommunicationIdentifier
<xref:RemoteParticipant.identifier> 與給定的 RemoteVideoStreamState 相關聯。 如果釋放 LocalVideoStreamState,則可能為 undefined。
要釋放的 LocalVideoStreamState 或 RemoteVideoStreamState。
getState()
保存我們可以從 CallClient <xref:%40azure%2Fcommunication-calling%23CallClient> 代理為 CallClientState CallClientState 的所有狀態。
function getState(): CallClientState
傳回
offStateChange((state: CallClientState) => void)
允許取消註冊 『stateChanged』 事件。
function offStateChange(handler: (state: CallClientState) => void)
參數
- handler
-
(state: CallClientState) => void
要取消訂閱的原始回呼。
onStateChange((state: CallClientState) => void)
允許針對 『stateChanged』 事件註冊處理程式。
function onStateChange(handler: (state: CallClientState) => void)
參數
- handler
-
(state: CallClientState) => void
回呼以接收狀態。
繼承的方法的詳細資料
dispose()
釋放此 CallClient,該 CallClient 也會釋放關聯的 設備管理員 和關聯的呼叫代理。
function dispose(): Promise<void>
傳回
Promise<void>
繼承自 CallClient.dispose
feature<TFeature>(CallClientFeatureFactory<TFeature>)
擷取具有擴充 API 的初始化和備忘功能物件。 檢查物件 Features.* 以取得此套件中所有可用的擴展呼叫用戶端功能。
function feature<TFeature>(factory: CallClientFeatureFactory<TFeature>): TFeature
參數
- factory
-
CallClientFeatureFactory<TFeature>
提供擴展 API 的 call 用戶端功能構造函數的工廠。
傳回
TFeature
繼承自 CallClient.feature
getDeviceManager()
DeviceManager 用於處理媒體設備,例如相機、麥克風和揚聲器。
function getDeviceManager(): Promise<DeviceManager>
傳回
Promise<DeviceManager>
繼承自 調用 Client.getDeviceManager