Check-in
1. Feature Overview
This module is primarily used to receive and process check-in operations initiated by users such as instructors, teaching assistants, and administrators.
2. API Methods
2.1 Get Check-in Information
Description: Retrieves the current user's check-in status information.
API Method: getCheckInInfo(): Promise<CheckInStatusSocketData>
Return Value Description: Check-in status data, type Promise<CheckInStatusSocketData>. Detailed type description is as follows:
| Property | Description | Type |
|---|---|---|
code |
Status code, 200 for successful check-in, 201 for not checked in | number |
data |
Check-in status data | CheckInStatusData[] |
Example:
const res = await watchCore.checkIn.getCheckInInfo();
if (res.code === 200) {
console.log('创建时间', res.data[0].createTime);
console.log('签到状态', res.data[0].checked);
console.log('签到ID', res.data[0].checkinId);
console.log('签到场次ID', res.data[0].sessionId);
}
2.2 Perform Check-in Operation
Description: Executes the check-in operation. A successful check-in triggers the SIGN_IN_SUCCESS event, while a failure triggers the SIGN_IN_FAIL event.
API Method: toCheckIn(): Promise<void>
Example:
await watchCore.checkIn.toCheckIn();
3. Module Events
3.1 Check-in Start Event
Description: Triggered when an instructor/teaching assistant initiates a check-in. Contains detailed check-in information.
Event: CheckInEvents.SIGN_IN
Callback Parameters: Object object. Detailed type description is as follows:
| Property | Description | Type |
|---|---|---|
roomId |
Channel ID | string |
checkInData |
Check-in data | CheckInData |
Example:
watchCore.checkIn.eventEmitter.on(CheckInEvents.SIGN_IN, (data) => {
console.log('签到开始', data.checkInData);
});
3.2 Check-in End Event
Description: Triggered when the check-in is manually stopped.
Event: CheckInEvents.STOP_SIGN_IN
Example:
watchCore.checkIn.eventEmitter.on(CheckInEvents.STOP_SIGN_IN, () => {
console.log('签到已结束');
});
3.3 Check-in Success Event
Description: Triggered when a user successfully completes the check-in.
Event: CheckInEvents.SIGN_IN_SUCCESS
Example:
watchCore.checkIn.eventEmitter.on(CheckInEvents.SIGN_IN_SUCCESS, () => {
console.log('签到成功');
});
3.4 Check-in Failure Event
Description: Triggered when a user fails to check in.
Event: CheckInEvents.SIGN_IN_FAIL
Example:
watchCore.checkIn.eventEmitter.on(CheckInEvents.SIGN_IN_FAIL, () => {
console.log('签到失败');
});
