agora-react-native-rtm
Version:
React Native around the Agora RTM SDKs for Android and iOS agora
117 lines (116 loc) • 7.1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RtmLockInternal = void 0;
var _RTMLock = require("../api/RTMLock");
var _IAgoraRtmLockImpl = require("../legacy/impl/IAgoraRtmLockImpl");
var _IrisRtmEngine = require("./IrisRtmEngine");
class RtmLockInternal extends _RTMLock.RTMLock {
_rtmLockImpl = new _IAgoraRtmLockImpl.IRtmLockImpl();
async setLock(channelName, channelType, lockName, options) {
let operation = 'setLock';
let callBack = 'onSetLockResult';
try {
var _result$callBackResul, _result$callBackResul2, _result$callBackResul3;
const status = this._rtmLockImpl.setLock(channelName, channelType, lockName, (options === null || options === void 0 ? void 0 : options.ttl) ?? 0);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
timestamp: result.timestamp,
channelName: (_result$callBackResul = result.callBackResult) === null || _result$callBackResul === void 0 ? void 0 : _result$callBackResul.channelName,
channelType: (_result$callBackResul2 = result.callBackResult) === null || _result$callBackResul2 === void 0 ? void 0 : _result$callBackResul2.channelType,
lockName: (_result$callBackResul3 = result.callBackResult) === null || _result$callBackResul3 === void 0 ? void 0 : _result$callBackResul3.lockName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async removeLock(channelName, channelType, lockName) {
let operation = 'removeLock';
let callBack = 'onRemoveLockResult';
try {
var _result$callBackResul4, _result$callBackResul5, _result$callBackResul6;
const status = this._rtmLockImpl.removeLock(channelName, channelType, lockName);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
timestamp: result.timestamp,
channelName: (_result$callBackResul4 = result.callBackResult) === null || _result$callBackResul4 === void 0 ? void 0 : _result$callBackResul4.channelName,
channelType: (_result$callBackResul5 = result.callBackResult) === null || _result$callBackResul5 === void 0 ? void 0 : _result$callBackResul5.channelType,
lockName: (_result$callBackResul6 = result.callBackResult) === null || _result$callBackResul6 === void 0 ? void 0 : _result$callBackResul6.lockName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async acquireLock(channelName, channelType, lockName, options) {
let operation = 'acquireLock';
let callBack = 'onAcquireLockResult';
try {
var _result$callBackResul7, _result$callBackResul8, _result$callBackResul9;
const status = this._rtmLockImpl.acquireLock(channelName, channelType, lockName, (options === null || options === void 0 ? void 0 : options.retry) ?? false);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
timestamp: result.timestamp,
channelName: (_result$callBackResul7 = result.callBackResult) === null || _result$callBackResul7 === void 0 ? void 0 : _result$callBackResul7.channelName,
channelType: (_result$callBackResul8 = result.callBackResult) === null || _result$callBackResul8 === void 0 ? void 0 : _result$callBackResul8.channelType,
lockName: (_result$callBackResul9 = result.callBackResult) === null || _result$callBackResul9 === void 0 ? void 0 : _result$callBackResul9.lockName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async releaseLock(channelName, channelType, lockName) {
let operation = 'releaseLock';
let callBack = 'onReleaseLockResult';
try {
var _result$callBackResul10, _result$callBackResul11, _result$callBackResul12;
const status = this._rtmLockImpl.releaseLock(channelName, channelType, lockName);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
timestamp: result.timestamp,
channelName: (_result$callBackResul10 = result.callBackResult) === null || _result$callBackResul10 === void 0 ? void 0 : _result$callBackResul10.channelName,
channelType: (_result$callBackResul11 = result.callBackResult) === null || _result$callBackResul11 === void 0 ? void 0 : _result$callBackResul11.channelType,
lockName: (_result$callBackResul12 = result.callBackResult) === null || _result$callBackResul12 === void 0 ? void 0 : _result$callBackResul12.lockName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async revokeLock(channelName, channelType, lockName, owner) {
let operation = 'revokeLock';
let callBack = 'onRevokeLockResult';
try {
var _result$callBackResul13, _result$callBackResul14, _result$callBackResul15;
const status = this._rtmLockImpl.revokeLock(channelName, channelType, lockName, owner);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
timestamp: result.timestamp,
channelName: (_result$callBackResul13 = result.callBackResult) === null || _result$callBackResul13 === void 0 ? void 0 : _result$callBackResul13.channelName,
channelType: (_result$callBackResul14 = result.callBackResult) === null || _result$callBackResul14 === void 0 ? void 0 : _result$callBackResul14.channelType,
lockName: (_result$callBackResul15 = result.callBackResult) === null || _result$callBackResul15 === void 0 ? void 0 : _result$callBackResul15.lockName
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
async getLock(channelName, channelType) {
let operation = 'getLock';
let callBack = 'onGetLocksResult';
try {
var _result$callBackResul16, _result$callBackResul17, _result$callBackResul18, _result$callBackResul19;
const status = this._rtmLockImpl.getLocks(channelName, channelType);
let result = await (0, _IrisRtmEngine.wrapRtmResult)(status, operation, callBack, true);
return {
timestamp: result.timestamp,
channelName: (_result$callBackResul16 = result.callBackResult) === null || _result$callBackResul16 === void 0 ? void 0 : _result$callBackResul16.channelName,
channelType: (_result$callBackResul17 = result.callBackResult) === null || _result$callBackResul17 === void 0 ? void 0 : _result$callBackResul17.channelType,
totalLocks: (_result$callBackResul18 = result.callBackResult) === null || _result$callBackResul18 === void 0 ? void 0 : _result$callBackResul18.count,
lockDetails: (_result$callBackResul19 = result.callBackResult) === null || _result$callBackResul19 === void 0 ? void 0 : _result$callBackResul19.lockDetailList
};
} catch (error) {
throw (0, _IrisRtmEngine.handleError)(error, operation);
}
}
}
exports.RtmLockInternal = RtmLockInternal;
//# sourceMappingURL=RtmLockInternal.js.map