import { HMSMessage } from '../schema'; import { IHMSBridge } from '../IHMSBridge'; import * as sdkTypes from './sdkTypes'; import { HMSSdk } from '@100mslive/100ms-web-sdk'; import { IHMSStore } from '../IHMSStore'; import SDKHMSException from '@100mslive/100ms-web-sdk/dist/error/HMSException'; /** * This class implements the HMSBridge interface for 100ms SDK. It connects with SDK * and takes control of data management by letting every action pass through it. The * passed in store is ensured to be the single source of truth reflecting current * room related data at any point in time. * * @privateRemarks * Things to keep in mind while updating store - * 1. Treat setState as an atomic operation, if an action results in multiple changes, * the changes should all happen within single setState function. * 2. While updating the state it's very important to not update the reference if * something is unchanged. Copy data in same reference object don't assign new * object. * 3. Mental Model(1) - Actions from backend -> Listeners of this class -> update store -> views update themselves * eg. for this - peer added, remote muted etc. * 4. Mental Model(2) - Actions from local -> View calls actions -> update store -> views update themselves * eg. local track enabled, join, leave etc. * 5. State is immutable, a new copy with new references is created when there is a change, * if you try to modify state outside of setState, there'll be an error. */ export declare class HMSSDKBridge implements IHMSBridge { private hmsSDKTracks; private readonly sdk; private readonly store; private isRoomJoinCalled; constructor(sdk: HMSSdk, store: IHMSStore); join(config: sdkTypes.HMSConfig): void; leave(): Promise; setScreenShareEnabled(enabled: boolean): Promise; setLocalAudioEnabled(enabled: boolean): Promise; setLocalVideoEnabled(enabled: boolean): Promise; setAudioSettings(settings: Partial): Promise; setVideoSettings(settings: Partial): Promise; sendMessage(message: string): void; attachVideo(trackID: string, videoElement: HTMLVideoElement): Promise; detachVideo(trackID: string, videoElement: HTMLVideoElement): Promise; private resetState; private sdkJoinWithListeners; private startScreenShare; private stopScreenShare; private setEnabledTrack; /** * This is a very important function as it's responsible for maintaining the source of * truth with maximum efficiency. The efficiency comes from the fact that the only * those portions of the store are updated which have actually changed. * While making a change in this function don't use functions like map, reduce etc. * which return a new copy of the data. Use Object.assign etc. to ensure that if the data * doesn't change reference is also not changed. * The UI and selectors rely on the fact that the store is immutable that is if there is * any change and only if there is a change, they'll get a new copy of the data they're * interested in with a new reference. * @protected */ protected syncPeers(): void; protected onJoin(sdkRoom: sdkTypes.HMSRoom): void; protected onRoomUpdate(): void; protected onPeerUpdate(type: sdkTypes.HMSPeerUpdate): void; protected onTrackUpdate(): void; protected onMessageReceived(sdkMessage: sdkTypes.HMSMessage): void; protected onHMSMessage(hmsMessage: HMSMessage): void; protected onAudioLevelUpdate(sdkSpeakers: sdkTypes.HMSSpeaker[]): void; protected onError(error: SDKHMSException): void; private setEnabledSDKTrack; private setSDKLocalTrackSettings; private enrichHMSTrack; private getMediaSettings; private logPossibleInconsistency; }