UNPKG

@azure/communication-react

Version:

React library for building modern communication user experiences utilizing Azure Communication Services

574 lines • 22.8 kB
import { CallIdChangedListener, DisplayNameChangedListener, IsMutedChangedListener, IsLocalScreenSharingActiveChangedListener, IsSpeakingChangedListener, ParticipantsJoinedListener, ParticipantsLeftListener, CallEndedListener } from '../../CallComposite'; import { RealTimeTextReceivedListener } from '../../CallComposite/adapter/CallAdapter'; import { MessageDeletedListener, MessageEditedListener, MessageReadListener, MessageReceivedListener, MessageSentListener, ParticipantsAddedListener, ParticipantsRemovedListener } from '../../ChatComposite'; import { ResourceDetails } from '../../ChatComposite'; import { CallWithChatAdapterState } from '../state/CallWithChatAdapterState'; import type { AdapterError, AdapterState, Disposable } from '../../common/adapters'; import { AudioDeviceInfo, Call, DeviceAccess, PermissionConstraints, PropertyChangedEvent, StartCallOptions, VideoDeviceInfo } from '@azure/communication-calling'; import { Reaction } from '@azure/communication-calling'; import { AddPhoneNumberOptions } from '@azure/communication-calling'; import { BreakoutRoomsUpdatedListener } from '@azure/communication-calling'; import { DtmfTone } from '@azure/communication-calling'; import { CreateVideoStreamViewResult, VideoStreamOptions } from "../../../../../react-components/src"; import { TogetherModeStreamViewResult, TogetherModeStreamOptions } from "../../../../../react-components/src"; import { SendMessageOptions } from '@azure/communication-chat'; import { JoinCallOptions, StartCaptionsAdapterOptions, StopCaptionsAdapterOptions } from '../../CallComposite/adapter/CallAdapter'; import { PhoneNumberIdentifier } from '@azure/communication-common'; import { UnknownIdentifier, MicrosoftTeamsAppIdentifier } from '@azure/communication-common'; import { CommunicationUserIdentifier } from '@azure/communication-common'; import { MicrosoftTeamsUserIdentifier } from '@azure/communication-common'; import { CommunicationIdentifier } from '@azure/communication-common'; import { CaptionsReceivedListener, IsCaptionsActiveChangedListener, IsCaptionLanguageChangedListener, IsSpokenLanguageChangedListener } from '../../CallComposite/adapter/CallAdapter'; import { CapabilitiesChangedListener } from '../../CallComposite/adapter/CallAdapter'; import { SpotlightChangedListener } from '../../CallComposite/adapter/CallAdapter'; import { VideoBackgroundImage, VideoBackgroundEffect } from '../../CallComposite'; import { CallSurvey, CallSurveyResponse } from '@azure/communication-calling'; /** * Functionality for managing the current call with chat. * @public */ export interface CallWithChatAdapterManagement { /** * Remove a participant from a Call. * * @param userId - UserId of the participant to remove. * * @public */ removeParticipant(userId: string): Promise<void>; /** * Remove a participant from the call. * @param participant - {@link @azure/communication-common#CommunicationIdentifier} of the participant to be removed * @public */ removeParticipant(participant: CommunicationIdentifier): Promise<void>; /** * Join the call with microphone initially on/off. * @deprecated Use joinCall(options?:JoinCallOptions) instead. * @param microphoneOn - Whether microphone is initially enabled * * @public */ joinCall(microphoneOn?: boolean): Call | undefined; /** * Join the call with options bag to set microphone/camera initial state when joining call * true = turn on the device when joining call * false = turn off the device when joining call * 'keep'/undefined = retain devices' precall state * * @param options - param to set microphone/camera initially on/off/use precall state. * * @public */ joinCall(options?: JoinCallOptions): Call | undefined; /** * Leave the call. * * @param forEveryone - Whether to remove all participants when leaving * * @public */ leaveCall(forEveryone?: boolean): Promise<void>; /** * Start the camera. * * This method will start rendering a local camera view when the call is not active. * * @param options - Options to control how video streams are rendered {@link @azure/communication-calling#VideoStreamOptions } * * @public */ startCamera(options?: VideoStreamOptions): Promise<void>; /** * Stop the camera. * * This method will stop rendering a local camera view when the call is not active. * * @public */ stopCamera(): Promise<void>; /** * Mute the current user during the call or disable microphone locally. * * @public */ mute(): Promise<void>; /** * Unmute the current user during the call or enable microphone locally. * * @public */ unmute(): Promise<void>; /** * Start the call. * * @param participants - An array of participant ids to join * * @public */ startCall(participants: string[], options?: StartCallOptions): Call | undefined; /** * Start the call. * @param participants - An array of {@link @azure/communication-common#CommunicationIdentifier} to be called * @public */ startCall(participants: (MicrosoftTeamsAppIdentifier | PhoneNumberIdentifier | CommunicationUserIdentifier | MicrosoftTeamsUserIdentifier | UnknownIdentifier)[], options?: StartCallOptions): Call | undefined; /** * Start sharing the screen during a call. * * @public */ startScreenShare(): Promise<void>; /** * Stop sharing the screen. * * @public */ stopScreenShare(): Promise<void>; /** * Raise hand for local user. * * @public */ raiseHand(): Promise<void>; /** * Lower hand for local user. * * @public */ lowerHand(): Promise<void>; /** * Send Reaction to ongoing meeting. * @param reaction - A value of type {@link @azure/communication-calling#Reaction} * * @public */ onReactionClick(reaction: Reaction): Promise<void>; /** * Create the html view for a stream. * * @remarks * This method is implemented for composite. * * @param remoteUserId - Id of the participant to render, leave it undefined to create the local camera view * @param options - Options to control how video streams are rendered {@link @azure/communication-calling#VideoStreamOptions } * * @public */ createStreamView(remoteUserId?: string, options?: VideoStreamOptions): Promise<void | CreateVideoStreamViewResult>; /** * Dispose the html view for a stream. * * @remarks * This method is implemented for composite. * * @param remoteUserId - Id of the participant to render, leave it undefined to dispose the local camera view * @param options - Options to control how video streams are rendered {@link @azure/communication-calling#VideoStreamOptions } * * @public */ disposeStreamView(remoteUserId?: string, options?: VideoStreamOptions): Promise<void>; /** * Create the html view for a togethermode stream. * * @remarks * This method is implemented for composite * * @param options - Options to control how video streams are rendered {@link @azure/communication-calling#VideoStreamOptions } * * @public */ createTogetherModeStreamView(options?: TogetherModeStreamOptions): Promise<void | TogetherModeStreamViewResult>; /** * Start together mode. * * @remarks * This method is implemented for composite * * * @public */ startTogetherMode(): Promise<void>; /** * Recalculate the seating positions for together mode. * * @remarks * This method is implemented for composite * * @param width - Width of the container * @param height - Height of the container * * @public */ setTogetherModeSceneSize(width: number, height: number): void; /** * Dispose the html view for a togethermode stream. * * @remarks * This method is implemented for composite * * @public */ disposeTogetherModeStreamView(): Promise<void>; /** * Dispose the html view for a screen share stream * * @remarks * this method is implemented for composite * * @param remoteUserId - Id of the participant to dispose the screen share stream view for. * * @public */ disposeScreenShareStreamView(remoteUserId: string): Promise<void>; /** * Dispose the html view for a remote video stream * * @param remoteUserId - Id of the participant to dispose * * @public */ disposeRemoteVideoStreamView(remoteUserId: string): Promise<void>; /** * Dispose the html view for a local video stream * * @public */ disposeLocalVideoStreamView(): Promise<void>; /** * Ask for permissions of devices. * * @remarks * Browser permission window will pop up if permissions are not granted yet. * * @param constrain - Define constraints for accessing local devices {@link @azure/communication-calling#PermissionConstraints } * * @public */ askDevicePermission(constrain: PermissionConstraints): Promise<DeviceAccess>; /** * Query for available camera devices. * * @remarks * This method should be called after askDevicePermission() * * @return An array of video device information entities {@link @azure/communication-calling#VideoDeviceInfo } * * @public */ queryCameras(): Promise<VideoDeviceInfo[]>; /** * Query for available microphone devices. * * @remarks * This method should be called after askDevicePermission() * * @return An array of audio device information entities {@link @azure/communication-calling#AudioDeviceInfo } * * @public */ queryMicrophones(): Promise<AudioDeviceInfo[]>; /** * Query for available microphone devices. * * @remarks * This method should be called after askDevicePermission() * * @return An array of audio device information entities {@link @azure/communication-calling#AudioDeviceInfo } * * @public */ querySpeakers(): Promise<AudioDeviceInfo[]>; /** * Set the camera to use in the call. * * @param sourceInfo - Camera device to choose, pick one returned by {@link CallAdapterDeviceManagement#queryCameras } * @param options - Options to control how the camera stream is rendered {@link @azure/communication-calling#VideoStreamOptions } * * @public */ setCamera(sourceInfo: VideoDeviceInfo, options?: VideoStreamOptions): Promise<void>; /** * Set the microphone to use in the call. * * @param sourceInfo - Microphone device to choose, pick one returned by {@link CallAdapterDeviceManagement#queryMicrophones } * * @public */ setMicrophone(sourceInfo: AudioDeviceInfo): Promise<void>; /** * Set the speaker to use in the call. * * @param sourceInfo - Speaker device to choose, pick one returned by {@link CallAdapterDeviceManagement#querySpeakers } * * @public */ setSpeaker(sourceInfo: AudioDeviceInfo): Promise<void>; /** * Fetch initial state for the Chat adapter. * * Performs the minimal fetch necessary for ChatComposite and API methods. * * @public */ fetchInitialData(): Promise<void>; /** * Send a message in the thread. * * @public */ sendMessage(content: string, options?: SendMessageOptions): Promise<void>; /** * Send a read receipt for a message. * * @public */ sendReadReceipt(chatMessageId: string): Promise<void>; /** * Send typing indicator in the thread. * * @public */ sendTypingIndicator(): Promise<void>; /** * Update a message content. * * @public */ updateMessage(messageId: string, content: string, options?: Record<string, string>): Promise<void>; /** * Delete a message in the thread. * * @public */ deleteMessage(messageId: string): Promise<void>; /** * Load more previous messages in the chat thread history. * * @remarks * This method is usually used to control incremental fetch/infinite scroll. * * @public */ loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>; /** @public */ downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void>; /** @public */ removeResourceFromCache(resourceDetails: ResourceDetails): void; /** * Puts the Call in a Localhold. * * @public */ holdCall(): Promise<void>; /** * Resumes the call from a LocalHold state. * * @public */ resumeCall(): Promise<void>; /** * Adds a new Participant to the call. * * @public */ addParticipant(participant: PhoneNumberIdentifier, options?: AddPhoneNumberOptions): Promise<void>; addParticipant(participant: CommunicationUserIdentifier): Promise<void>; /** * send dtmf tone to another participant in the call in 1:1 calls * * @public */ sendDtmfTone: (dtmfTone: DtmfTone) => Promise<void>; /** * Function to Start captions * @param options - options for start captions */ startCaptions(options?: StartCaptionsAdapterOptions): Promise<void>; /** * Function to set caption language * @param language - language set for caption */ setCaptionLanguage(language: string): Promise<void>; /** * Function to set spoken language * @param language - spoken language */ setSpokenLanguage(language: string): Promise<void>; /** * Funtion to stop captions */ stopCaptions(options?: StopCaptionsAdapterOptions): Promise<void>; /** * Start the video background effect. * * @public */ startVideoBackgroundEffect(videoBackgroundEffect: VideoBackgroundEffect): Promise<void>; /** * Stop the video background effect. * * @public */ stopVideoBackgroundEffects(): Promise<void>; /** * Override the background picker images for background replacement effect. * * @param backgroundImages - Array of custom background images. * * @public */ updateBackgroundPickerImages(backgroundImages: VideoBackgroundImage[]): void; /** * Update the selected video background effect * * @public */ updateSelectedVideoBackgroundEffect(selectedVideoBackground: VideoBackgroundEffect): void; /** * Start the noise suppression effect. */ startNoiseSuppressionEffect(): Promise<void>; /** * Start the noise suppression effect. */ stopNoiseSuppressionEffect(): Promise<void>; /** * Send the end of call survey result * * @public */ submitSurvey(survey: CallSurvey): Promise<CallSurveyResponse | undefined>; /** * Start spotlight */ startSpotlight(userIds?: string[]): Promise<void>; /** * Stop spotlight */ stopSpotlight(userIds?: string[]): Promise<void>; /** * Stop all spotlights */ stopAllSpotlight(): Promise<void>; /** * Mute a participant */ muteParticipant(userId: string): Promise<void>; /** * Mute a participant */ muteAllRemoteParticipants(): Promise<void>; /** * Return to origin call of breakout room */ returnFromBreakoutRoom(): Promise<void>; /** * forbids audio for the specified user ids. */ forbidAudio: (userIds: string[]) => Promise<void>; /** permits audio for the specified user ids. */ permitAudio: (userIds: string[]) => Promise<void>; /** forbids audio for Teams meeting attendees except the local user. */ forbidOthersAudio: () => Promise<void>; /** permits audio for Teams meeting attendees except the local user. */ permitOthersAudio: () => Promise<void>; /** forbids video for the specified user ids. */ forbidVideo: (userIds: string[]) => Promise<void>; /** permits video for the specified user ids. */ permitVideo: (userIds: string[]) => Promise<void>; /** forbids video for Teams meeting attendees except the local user. */ forbidOthersVideo: () => Promise<void>; /** permits video for Teams meeting attendees except the local user. */ permitOthersVideo: () => Promise<void>; /** * Send real time text * @param text - real time text content * @param finalized - Boolean to indicate if the real time text is final */ sendRealTimeText: (text: string, isFinalized: boolean) => Promise<void>; } /** * Call and Chat events that can be subscribed to in the {@link CallWithChatAdapter}. * @public */ export interface CallWithChatAdapterSubscriptions { on(event: 'callEnded', listener: CallEndedListener): void; on(event: 'isMutedChanged', listener: IsMutedChangedListener): void; on(event: 'callIdChanged', listener: CallIdChangedListener): void; on(event: 'isLocalScreenSharingActiveChanged', listener: IsLocalScreenSharingActiveChangedListener): void; on(event: 'displayNameChanged', listener: DisplayNameChangedListener): void; on(event: 'isSpeakingChanged', listener: IsSpeakingChangedListener): void; on(event: 'callParticipantsJoined', listener: ParticipantsJoinedListener): void; on(event: 'callParticipantsLeft', listener: ParticipantsLeftListener): void; on(event: 'selectedMicrophoneChanged', listener: PropertyChangedEvent): void; on(event: 'selectedSpeakerChanged', listener: PropertyChangedEvent): void; on(event: 'callError', listener: (e: AdapterError) => void): void; on(event: 'captionsReceived', listener: CaptionsReceivedListener): void; on(event: 'isCaptionsActiveChanged', listener: IsCaptionsActiveChangedListener): void; on(event: 'isCaptionLanguageChanged', listener: IsCaptionLanguageChangedListener): void; on(event: 'isSpokenLanguageChanged', listener: IsSpokenLanguageChangedListener): void; on(event: 'realTimeTextReceived', listener: RealTimeTextReceivedListener): void; on(event: 'capabilitiesChanged', listener: CapabilitiesChangedListener): void; on(event: 'spotlightChanged', listener: SpotlightChangedListener): void; on(event: 'breakoutRoomsUpdated', listener: BreakoutRoomsUpdatedListener): void; off(event: 'callEnded', listener: CallEndedListener): void; off(event: 'isMutedChanged', listener: IsMutedChangedListener): void; off(event: 'callIdChanged', listener: CallIdChangedListener): void; off(event: 'isLocalScreenSharingActiveChanged', listener: IsLocalScreenSharingActiveChangedListener): void; off(event: 'displayNameChanged', listener: DisplayNameChangedListener): void; off(event: 'isSpeakingChanged', listener: IsSpeakingChangedListener): void; off(event: 'callParticipantsJoined', listener: ParticipantsJoinedListener): void; off(event: 'callParticipantsLeft', listener: ParticipantsLeftListener): void; off(event: 'selectedMicrophoneChanged', listener: PropertyChangedEvent): void; off(event: 'selectedSpeakerChanged', listener: PropertyChangedEvent): void; off(event: 'callError', listener: (e: AdapterError) => void): void; off(event: 'captionsReceived', listener: CaptionsReceivedListener): void; off(event: 'isCaptionsActiveChanged', listener: IsCaptionsActiveChangedListener): void; off(event: 'isCaptionLanguageChanged', listener: IsCaptionLanguageChangedListener): void; off(event: 'isSpokenLanguageChanged', listener: IsSpokenLanguageChangedListener): void; off(event: 'realTimeTextReceived', listener: RealTimeTextReceivedListener): void; off(event: 'capabilitiesChanged', listener: CapabilitiesChangedListener): void; off(event: 'spotlightChanged', listener: SpotlightChangedListener): void; off(event: 'breakoutRoomsUpdated', listener: BreakoutRoomsUpdatedListener): void; on(event: 'messageReceived', listener: MessageReceivedListener): void; on(event: 'messageEdited', listener: MessageEditedListener): void; on(event: 'messageDeleted', listener: MessageDeletedListener): void; on(event: 'messageSent', listener: MessageSentListener): void; on(event: 'messageRead', listener: MessageReadListener): void; on(event: 'chatParticipantsAdded', listener: ParticipantsAddedListener): void; on(event: 'chatParticipantsRemoved', listener: ParticipantsRemovedListener): void; on(event: 'chatError', listener: (e: AdapterError) => void): void; off(event: 'messageReceived', listener: MessageReceivedListener): void; off(event: 'messageEdited', listener: MessageEditedListener): void; off(event: 'messageDeleted', listener: MessageDeletedListener): void; off(event: 'messageSent', listener: MessageSentListener): void; off(event: 'messageRead', listener: MessageReadListener): void; off(event: 'chatParticipantsAdded', listener: ParticipantsAddedListener): void; off(event: 'chatParticipantsRemoved', listener: ParticipantsRemovedListener): void; off(event: 'chatError', listener: (e: AdapterError) => void): void; on(event: 'chatInitialized', listener: ChatInitializedListener): void; off(event: 'chatInitialized', listener: ChatInitializedListener): void; } /** * Callback for {@link CallWithChatAdapterSubscribers} 'chatInitialized' event. * * @public */ export type ChatInitializedListener = (event: { adapter: CallWithChatAdapter; }) => void; /** * {@link CallWithChatComposite} Adapter interface. * * @public */ export interface CallWithChatAdapter extends CallWithChatAdapterManagement, AdapterState<CallWithChatAdapterState>, Disposable, CallWithChatAdapterSubscriptions { } /** * Events fired off by the {@link CallWithChatAdapter}. * * @public */ export type CallWithChatEvent = 'callError' | 'chatError' | 'callEnded' | 'isMutedChanged' | 'callIdChanged' | 'isLocalScreenSharingActiveChanged' | 'displayNameChanged' | 'isSpeakingChanged' | 'callParticipantsJoined' | 'callParticipantsLeft' | 'selectedMicrophoneChanged' | 'selectedSpeakerChanged' | 'isCaptionsActiveChanged' | 'captionsReceived' | 'isCaptionLanguageChanged' | 'isSpokenLanguageChanged' | 'realTimeTextReceived' | 'capabilitiesChanged' | 'spotlightChanged' | 'breakoutRoomsUpdated' | 'messageReceived' | 'messageEdited' | 'messageDeleted' | 'messageSent' | 'messageRead' | 'chatParticipantsAdded' | 'chatParticipantsRemoved' | 'chatInitialized'; //# sourceMappingURL=CallWithChatAdapter.d.ts.map