import { NativeModules } from 'react-native'; import { ZoomVideoSdkVideoStatus } from './ZoomVideoSdkVideoStatus'; import { ZoomVideoSdkAudioStatus } from './ZoomVideoSdkAudioStatus'; import { ZoomVideoSdkVideoStatisticInfo } from './ZoomVideoSdkVideoStatisticInfo'; import { ZoomVideoSdkShareStatisticInfo } from './ZoomVideoSdkShareStatisticInfo'; import { ShareAction, WhiteboardStatus } from './ZoomVideoSdk'; const { RNZoomVideoSdkUser } = NativeModules; /* * - Objective data types are for ease of use. In general, the user-related data is * obtained when the target user is retrieved: * * const mySelf: ZoomVideoSdkUserType = await zoom.session.getMySelf(); * if (mySelf.isHost) { * ... * } * * - Some of the info that changes frequently needs to be retrieved by async calls * and it needs to be made through the native methods: * * const mySelf: ZoomVideoSdkUserType = await zoom.session.getMySelf(); * const mySelfInstance: ZoomVideoSdkUser = new ZoommVideoSdkUser(mySelf); * const fps = await mySelfInstance.videoStatisticInfo.getFps(); * * - Async functions like getIsHost(), getIsManager(), getUserName return the current * values whereas the corresponding object data isHost, isManager, userName contains * the initial value when it's retrieved and never gets updated. * * const mySelf: ZoomVideoSdkUser = new ZoommVideoSdkUser(await zoom.session.getMySelf()); * const isManager = await mySelf.getIsManager(); * */ /** * Zoom Video SDK user information. */ export type ZoomVideoSdkUserType = { /** * The userId of the user object. */ userId: string; /** * User's custom identity that is passed in the JWT or in SDKSessionContext.customUserId */ customUserId: string; /** * User name. */ userName: string; /** * Determine whether the user is the host. */ isHost: boolean; /** * Determine whether the user is the manager. */ isManager: boolean; /** * Determine whether the user has multiple cameras. */ hasMultiCamera: boolean; /** * The index of the user's multi-camera stream. */ multiCameraIndex: string; /** * Determine whether the user is the host. */ getIsHost: () => Promise; /** * Determine whether the user is the manager. */ getIsManager: () => Promise; /** * Get the name of the user in the session. */ getUserName: () => Promise; /** * Get the user's share action information. */ getShareActionList: () => Promise; /** * The user video status. */ videoStatus: ZoomVideoSdkVideoStatus; /** * The user's audio status. */ audioStatus: ZoomVideoSdkAudioStatus; /** * The user's video statistic information. */ videoStatisticInfo: ZoomVideoSdkVideoStatisticInfo; /** * The user's screen share statistic information. */ shareStatisticInfo: ZoomVideoSdkShareStatisticInfo; /** * Get user volume. */ getUserVolume: (userId: string, isSharing: boolean) => Promise; /** * Set the user's local volume. This does not affect how other participants hear the user. */ setUserVolume: (userId: string, isSharing: boolean, volume: number) => Promise; /** * Determine which audio you can set, shared audio or microphone. */ canSetUserVolume: (userId: string, isSharing: boolean) => Promise; /** * Determine whether the user has individual recording consent. */ hasIndividualRecordingConsent: (userId: string) => Promise; /** * Get the user's reference. */ getUserReference: () => Promise; /** * Get the user's whiteboard status. */ getWhiteboardStatus: () => Promise; }; export class ZoomVideoSdkUser implements ZoomVideoSdkUserType { userId; customUserId; userName; isHost; isManager; hasMultiCamera; multiCameraIndex; videoStatus; audioStatus; videoStatisticInfo; shareStatisticInfo; constructor(user: ZoomVideoSdkUserType) { this.userId = user.userId; this.customUserId = user.customUserId; this.userName = user.userName; this.isHost = user.isHost; this.isManager = user.isManager; this.hasMultiCamera = false; this.multiCameraIndex = '0'; this.videoStatus = new ZoomVideoSdkVideoStatus(user.userId); this.audioStatus = new ZoomVideoSdkAudioStatus(user.userId); this.videoStatisticInfo = new ZoomVideoSdkVideoStatisticInfo(user.userId); this.shareStatisticInfo = new ZoomVideoSdkShareStatisticInfo(user.userId); } async getUserName() { return await RNZoomVideoSdkUser.getUserName(this.userId); } async getShareActionList() { const actionList = await RNZoomVideoSdkUser.getShareActionList(this.userId); return actionList.map((action: ShareAction) => new ShareAction(action)); } async getIsHost() { return await RNZoomVideoSdkUser.isHost(this.userId); } async getIsManager() { return await RNZoomVideoSdkUser.isManager(this.userId); } async getUserVolume(userId: string, isSharing: boolean) { return await RNZoomVideoSdkUser.getUserVolume(userId, isSharing); } async setUserVolume(userId: string, isSharing: boolean, volume: number) { return await RNZoomVideoSdkUser.setUserVolume(userId, volume, isSharing); } async canSetUserVolume(userId: string, isSharing: boolean) { return await RNZoomVideoSdkUser.canSetUserVolume(userId, isSharing); } async hasIndividualRecordingConsent(userId: string) { return await RNZoomVideoSdkUser.hasIndividualRecordingConsent(userId); } async getUserReference() { return await RNZoomVideoSdkUser.getUserReference(this.userId); } async getWhiteboardStatus() { const status = await RNZoomVideoSdkUser.getWhiteboardStatus(this.userId); return status as WhiteboardStatus; } }