UNPKG

agora-react-native-rtm

Version:

React Native around the Agora RTM SDKs for Android and iOS agora

209 lines (196 loc) 4.75 kB
import { callIrisApi } from '../../internal/IrisRtmEngine'; import { RtmChannelType } from '../AgoraRtmBase'; import { IRtmLock } from '../IAgoraRtmLock'; // @ts-ignore export class IRtmLockImpl implements IRtmLock { setLock( channelName: string, channelType: RtmChannelType, lockName: string, ttl: number ): any { const apiType = this.getApiTypeFromSetLock( channelName, channelType, lockName, ttl ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, ttl: ttl, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, ttl: ttl, }; }, }; return callIrisApi.call(this, apiType, jsonParams); } protected getApiTypeFromSetLock( channelName: string, channelType: RtmChannelType, lockName: string, ttl: number ): string { return 'RtmLock_setLock_89e5672'; } getLocks(channelName: string, channelType: RtmChannelType): any { const apiType = this.getApiTypeFromGetLocks(channelName, channelType); const jsonParams = { channelName: channelName, channelType: channelType, toJSON: () => { return { channelName: channelName, channelType: channelType, }; }, }; return callIrisApi.call(this, apiType, jsonParams); } protected getApiTypeFromGetLocks( channelName: string, channelType: RtmChannelType ): string { return 'RtmLock_getLocks_ad8568b'; } removeLock( channelName: string, channelType: RtmChannelType, lockName: string ): any { const apiType = this.getApiTypeFromRemoveLock( channelName, channelType, lockName ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, }; }, }; return callIrisApi.call(this, apiType, jsonParams); } protected getApiTypeFromRemoveLock( channelName: string, channelType: RtmChannelType, lockName: string ): string { return 'RtmLock_removeLock_4ffa44d'; } acquireLock( channelName: string, channelType: RtmChannelType, lockName: string, retry: boolean ): any { const apiType = this.getApiTypeFromAcquireLock( channelName, channelType, lockName, retry ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, retry: retry, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, retry: retry, }; }, }; return callIrisApi.call(this, apiType, jsonParams); } protected getApiTypeFromAcquireLock( channelName: string, channelType: RtmChannelType, lockName: string, retry: boolean ): string { return 'RtmLock_acquireLock_cd2dbc2'; } releaseLock( channelName: string, channelType: RtmChannelType, lockName: string ): any { const apiType = this.getApiTypeFromReleaseLock( channelName, channelType, lockName ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, }; }, }; return callIrisApi.call(this, apiType, jsonParams); } protected getApiTypeFromReleaseLock( channelName: string, channelType: RtmChannelType, lockName: string ): string { return 'RtmLock_releaseLock_4ffa44d'; } revokeLock( channelName: string, channelType: RtmChannelType, lockName: string, owner: string ): any { const apiType = this.getApiTypeFromRevokeLock( channelName, channelType, lockName, owner ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, owner: owner, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, owner: owner, }; }, }; return callIrisApi.call(this, apiType, jsonParams); } protected getApiTypeFromRevokeLock( channelName: string, channelType: RtmChannelType, lockName: string, owner: string ): string { return 'RtmLock_revokeLock_fc4a9d7'; } }