agora-edu-core
Version:
Core APIs for building an online classroom
286 lines (274 loc) • 9.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.HandUpStore = void 0;
var _agoraRteSdk = require("agora-rte-sdk");
var _ = require("../../../../");
var _error = require("../../../../utils/error");
var _base = require("../base");
var _type = require("./type");
var _class;
function _applyDecoratedDescriptor(i, e, r, n, l) { var a = {}; return Object.keys(n).forEach(function (i) { a[i] = n[i]; }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = r.slice().reverse().reduce(function (r, n) { return n(i, e, r) || r; }, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a; }
/**
* `HandUpStore` 类提供举手上台功能相关能力。
*/
/** @en
* The `HandUpStore` class provides abilities related to the hand-raising feature.
*/
let HandUpStore = exports.HandUpStore = (_class = class HandUpStore extends _base.EduStoreBase {
/**
* 同意学生上讲台
* @param userUuid 用户 ID
* @param source 邀请来源:
* - 老师从花名册邀请学生上讲台
* - 学生举手老师同意上讲台
**/
/** @en
* Allows a student to "go onto the stage"
* @param userUuid The user ID
* @param source The source:
* - The teacher requests the student in the user list to "go onto the stage".
* - The teacher accepts the student's application for "going onto the stage".
*/
async onPodium(userUuid) {
let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _type.PodiumSrouce.InvitedByTeacher;
try {
await this.api.acceptHandsUp({
roomUuid: this.classroomStore.connectionStore.sceneId,
toUserUuid: userUuid
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(source === _type.PodiumSrouce.AcceptedByTeacher ? _error.AGEduErrorCode.EDU_ERR_HAND_UP_ACCEPT_FAIL : _error.AGEduErrorCode.EDU_ERR_HAND_UP_ON_PODIUM_FAIL, err);
}
}
/**
* 让指定学生下讲台
* @param userUuid 用户 ID
*
**/
/** @en
* Lets a student "go off the stage"
* @param userUuid The user ID
*/
async offPodium(userUuid) {
try {
await this.api.revokeCoVideo({
roomUuid: this.classroomStore.connectionStore.sceneId,
toUserUuid: userUuid
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_HAND_UP_OFF_PODIUM_FAIL, err);
}
}
/**
* 让全部学生下讲台
**/
/** @en
* Lets all students "go off the stage"
*/
async offPodiumAll() {
try {
await this.api.revokeAllCoVideo({
roomUuid: this.classroomStore.connectionStore.sceneId
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_HAND_UP_OFF_PODIUM_ALL_FAIL, err);
}
}
/**
* @deprecated 使用 cancelHandUp 代替
* 拒绝举手上台请求
* @param userUuid 用户 ID
*
**/
/** @en
* @deprecated use cancelHandUp instead
* The teacher rejects the student's application for "going onto the stage"
* @param userUuid The user ID
*/
async rejectHandUp(userUuid) {
try {
await this.api.cancelHandsUp({
roomUuid: this.classroomStore.connectionStore.sceneId,
toUserUuid: userUuid
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_HAND_UP_REJECT_FAIL, err);
}
}
/**
* 取消举手
* @param userUuid 用户 ID
**/
/** @en
* cancel raising hand
* @param userUuid The user ID
*/
async cancelHandUp(userUuid) {
try {
await this.api.cancelHandsUp({
roomUuid: this.classroomStore.connectionStore.sceneId,
toUserUuid: userUuid
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_HAND_UP_CANCEL_FAIL, err);
}
}
/**
* 取消挥手
*/
/** @en
* cancels waving hand
*/
async cancelWaveArm(userUuid) {
try {
await this.api.cancelHandsWave({
roomUuid: this.classroomStore.connectionStore.sceneId,
toUserUuid: userUuid
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_HAND_UP_CANCEL_FAIL, err);
}
}
/**
* @internal
*
* 学生举手
* @param teacherUuid 老师 ID
*
**/
/** @en
* @internal
*
* The student raises a hand to apply for "going onto the stage"
* @param teacherUuid The teacher ID
*/
async handUp(teacherUuid) {
try {
await this.api.handsUp({
roomUuid: this.classroomStore.connectionStore.sceneId,
toUserUuid: teacherUuid
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_HAND_UP_HAND_UP_FAIL, err);
}
}
/**
* 学生挥手
* @param teacherUuid 老师 ID
* @param duration 超时时长
* @param payload 扩展信息
**/
/** @en
* The student waves a hand to apply for "going onto the stage"
* @param teacherUuid The teacher ID
* @param duration duration to timeout
* @param payload extra info
*/
async waveArm(teacherUuid, duration, payload) {
try {
await this.api.handsWave({
roomUuid: this.classroomStore.connectionStore.sceneId,
toUserUuid: teacherUuid,
timout: duration,
retry: true,
payload: payload
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_HAND_UP_WAVE_FAIL, err);
}
}
/**
* @deprecated 使用 handUp 替代
* 邀请学生上台互动
* @param userUuid 学生ID
* @param duration 超时时长
* @param payload 扩展信息
**/
/** @en
* @deprecated use handUp instead
* Invited students interaction
* @param userUuid The student ID
* @param duration duration to timeout
* @param payload extra info
*/
async invitePodium(userUuid, duration, payload) {
const {
sessionInfo
} = _.EduClassroomConfig.shared;
try {
await this.api.handsUp({
roomUuid: sessionInfo.roomUuid,
toUserUuid: userUuid,
timout: duration,
retry: true,
payload: payload
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_INVITE_PODIUM_FAIL, err);
}
}
/**
* @deprecated 使用 onPodium 替代
* 确认接受上台邀请
**/
/** @en
* @deprecated use onPodium instead
* Confirm the acceptance by the invitation
*/
async confirmInvited() {
const {
sessionInfo
} = _.EduClassroomConfig.shared;
try {
await this.api.acceptHandsUp({
roomUuid: sessionInfo.roomUuid
});
} catch (err) {
_error.EduErrorCenter.shared.handleThrowableError(_error.AGEduErrorCode.EDU_ERR_INVITE_CONFIRM_FAIL, err);
}
}
/**
* 配置允许学生举手
* @param state 是否允许举手,0 不允许,1 允许
* @param autoStage 是否开启自动上台
*/
/** @en
* Configure allowing students to raise hands
* @param state Whether allow raising hands or not, 0 not allowed, 1 allowed
* @param autoStage Whether 'auto up stage' is enabled or not
*/
allowHandsUp(state, autoStage) {
const {
sessionInfo
} = _.EduClassroomConfig.shared;
if (autoStage) {
this.api.allowHandsUp({
state,
roomUuid: sessionInfo.roomUuid,
defaultAcceptRole: 'audience'
});
} else {
this.api.allowHandsUp({
state,
roomUuid: sessionInfo.roomUuid,
defaultAcceptRole: ''
});
}
}
/**
* @internal
*/
/** @en
* @internal
*/
onInstall() {}
/**
* @internal
*/
/** @en
* @internal
*/
onDestroy() {}
}, _applyDecoratedDescriptor(_class.prototype, "onPodium", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "onPodium"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "offPodium", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "offPodium"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "offPodiumAll", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "offPodiumAll"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "rejectHandUp", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "rejectHandUp"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "cancelHandUp", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "cancelHandUp"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "cancelWaveArm", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "cancelWaveArm"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handUp", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "handUp"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "waveArm", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "waveArm"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "invitePodium", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "invitePodium"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "confirmInvited", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "confirmInvited"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "allowHandsUp", [_agoraRteSdk.bound], Object.getOwnPropertyDescriptor(_class.prototype, "allowHandsUp"), _class.prototype), _class);