fcr-core
Version:
Core APIs for building online scenes
113 lines (112 loc) • 3.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FcrStandaloneAnnotationControlImpl = exports.FcrAnnotationControlImpl = void 0;
var _error = require("../../../utilities/error");
var _logger = require("../../../utilities/logger");
var _base = require("../base");
var _constant = require("../constant");
var _type = require("../../whiteboard-control/type");
var _imports = require("agora-rte-sdk/lib/imports");
var _type2 = require("agora-rte-sdk/lib/type");
const addBoardConnectingObserver = (board, sceneConfig) => {
board.addObserver({
onConnectionStateUpdated: state => {
if (state === _type2.AgoraRteConnectionState.CONNECTED) {
if (sceneConfig.isAndroidByOwner()) {
board.getMainWindow()?.setAutoCancelDraw(true);
} else {
board.getMainWindow()?.setAutoCancelDraw(false);
}
}
}
});
};
class FcrAnnotationControlImpl extends _base.FcrBaseWhiteboardControlImpl {
logger = (0, _logger.createLogger)({
prefix: 'FcrAnnotationControlImpl'
});
constructor(rtmClient, config, forgeInitConfigFetcher, _sceneConfig, _api) {
super(rtmClient, config, forgeInitConfigFetcher, _api);
this.rtmClient = rtmClient;
this.config = config;
this._sceneConfig = _sceneConfig;
this._api = _api;
addBoardConnectingObserver(this, this._sceneConfig);
}
async syncScreenShareOwnerAnnotationOpenDone() {
try {
await this._api.syncScreenShareOwnerAnnotationOpenDone(this._sceneConfig.sceneId);
return 0;
} catch (e) {
const error = e;
const errorMessage = error.message;
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.FCR_ROOM_WHITEBOARD, _error.FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, `sync screen share owner annotation open done failed: ${errorMessage}`, errorMessage);
}
}
async syncWhiteboardWriteCount(isWritable) {
await (0, _error.handleRequestError)(() => this._api.setWhiteboardWriteCount({
roomId: this.config.roomId,
userId: this.config.userId,
state: isWritable ? 1 : 0
}), _imports.ErrorModuleCode.FCR_ROOM_WHITEBOARD, `set whiteboard write permission to ${isWritable} failed`);
return 0;
}
async open() {
const state = this._sceneConfig.getAnnotationState();
if (state === _type.FcrBoardPropertiesState.INACTIVE) {
return await super.internalOpen(true);
} else {
return await super.internalOpen(false);
}
}
getApplicationId() {
return _constant.ANNOTATION_APP_ID;
}
getWhiteboardOption() {
return {
width: this.config.size.width,
height: this.config.size.height,
defaultToolbarStyle: {
tool: 'laser'
},
maxScaleRatio: 1
};
}
}
exports.FcrAnnotationControlImpl = FcrAnnotationControlImpl;
class FcrStandaloneAnnotationControlImpl extends _base.FcrBaseWhiteboardControlImpl {
logger = (0, _logger.createLogger)({
prefix: 'FcrStandaloneAnnotationControlImpl'
});
constructor(rtmClient, config, forgeInitConfigFetcher, _sceneConfig) {
super(rtmClient, config, forgeInitConfigFetcher);
this.rtmClient = rtmClient;
this.config = config;
this._sceneConfig = _sceneConfig;
addBoardConnectingObserver(this, this._sceneConfig);
}
async open() {
const state = this._sceneConfig.getAnnotationState();
if (state === _type.FcrBoardPropertiesState.INACTIVE) {
return await super.internalOpen(true);
} else {
return await super.internalOpen(false);
}
}
getApplicationId() {
return _constant.ANNOTATION_APP_ID;
}
getWhiteboardOption() {
return {
width: this.config.size.width,
height: this.config.size.height,
defaultToolbarStyle: {
tool: 'laser'
},
maxScaleRatio: 1
};
}
}
exports.FcrStandaloneAnnotationControlImpl = FcrStandaloneAnnotationControlImpl;