agora-edu-core
Version:
Core APIs for building an online classroom
358 lines (357 loc) • 8.02 kB
TypeScript
import { AgoraCloudProxyObserver, AgoraComponentRegion, AgoraRteEngine, AgoraRteScene, AgoraRteSceneJoinRTCOptions, AGRtcConnectionType, AGRtcState } from 'agora-rte-sdk';
import { ClassroomState, EduSessionInfo } from '../../../type';
import { EduStoreBase } from './base';
import { ClassroomSchedule } from './room/type';
export declare type CheckInData = {
vid: number;
clientServerTime: number;
classRoomSchedule: ClassroomSchedule;
rtcRegion: AgoraComponentRegion;
rtmRegion: AgoraComponentRegion;
};
export declare enum LeaveReason {
leave = 0,
kickOut = 1
}
export declare enum SceneType {
Main = 0,
Sub = 1
}
/**
* `ConnectionStore` 类用于管理连接状态。
*/
/** @en
* The `ConnectionStore` class is used for managing connection states.
*/
export declare class ConnectionStore extends EduStoreBase {
private _cancelJoin?;
private _disposers;
private _rteRole?;
/**
* 房间连接状态
*/
/** @en
* Room connection state
*/
classroomState: ClassroomState;
/**
* @internal
*/
/** @en
* @internal
*/
subRoomState: ClassroomState;
/**
* @internal
*/
/** @en
* @internal
*/
classroomStateErrorReason?: string;
/**
* RTC 连接状态
*/
/** @en
* RTC connection state
*/
rtcState: AGRtcState;
/**
* @internal
*/
/** @en
* @internal
*/
rtcSubState: AGRtcState;
/**
* @internal
*/
/** @en
* @internal
*/
_mainRoomScene?: AgoraRteScene;
/**
* @internal
*/
/** @en
* @internal
*/
_subRoomScene?: AgoraRteScene;
/**
* RTE 引擎
*/
/** @en
* RTE engine
*/
engine?: AgoraRteEngine;
/**
* @internal
*/
/** @en
* @internal
*/
_mainRoomCheckInData?: CheckInData;
/**
* @internal
*/
/** @en
* @internal
*/
_subRoomCheckInData?: CheckInData;
/**
* @internal
*/
private _entryData?;
/**
* 当前场景对象
**/
/** @en
* current scene object
*/
get scene(): AgoraRteScene | undefined;
/**
* 当前场景 ID
**/
/** @en
* Current scene id
*/
get sceneId(): string;
/**
* @internal
*
* 大房间 scene
**/
/** @en
* @internal
*
* Scene of the main room
*/
get mainRoomScene(): AgoraRteScene | undefined;
/**
* @internal
*
* 子房间 scene
**/
/** @en
* @internal
*
* Scene of the sub room
*/
get subRoomScene(): AgoraRteScene | undefined;
/**
* @internal
*
* 大房间接入房间数据
**/
/** @en
* @internal
*
* CheckIn data of the main room
*/
get mainRoomCheckInData(): CheckInData | undefined;
/**
* @internal
*
* 子房间加入数据
**/
/** @en
* @internal
*
* CheckIn data of the sub room
*/
get subRoomCheckInData(): CheckInData | undefined;
/**
* 设置房间状态
* @param state 房间状态
* @param reason 原因
**/
/** @en
* Sets the room state
* @param state The room state
* @param reason The reason
*/
private _setClassroomState;
/**
* 设置子房间状态
* @param state 子房间状态
* @param reason 原因
*
**/
/** @en
* Sets the sub-room state
* @param state The classroom state
* @param reason The reason
*/
private _setSubRoomState;
/**
* 设置 RTC 状态
* @param state RTC 状态
* @param connectionType 大小房间
**/
/** @en
* Sets the RTC state
* @param state The RTC state
* @param connectionType Whether in the main room or in the sub-room
*
*/
private _setRtcState;
/**
* 设置 scene
* @param sceneType 大小房间类型
* @param scene
*
**/
/** @en
* Sets the current scene
* @param sceneType SceneType
* @param scene RteScene
*/
private _setScene;
/**
* 设置接入房间数据
* @param sceneType 房间类型
* @param checkInData 接入数据
*
**/
/** @en
* Sets the check-in data
* @param sceneType SceceType
* @param checkInData The check-in data
*/
private _setCheckInData;
/**
* 初始化 RTE engine
**/
/** @en
* Initializes RteEngine
*/
initialize(): void;
private _createEngine;
/**
* 获取当前 RteEngine,调用此方法获取实例前需要先调用 connectionStore.initialize, 否则将抛出异常
* @returns RTE engine
**/
/** @en
* Gets instance of RTE Engine, it will throw if this method gets called before calling connectionStore.initialize
* @returns RTE engine
*/
getEngine(): AgoraRteEngine;
/**
* 加入房间
*
**/
/** @en
* Joins the room
*/
joinClassroom(options?: {
mode: 'check-in' | 'entry';
}): Promise<undefined>;
private _throwEduJoinRoomError;
private _throwEduJoinSubRoomError;
entry(sessionInfo: EduSessionInfo, sceneType: SceneType): Promise<void>;
/**
* 进入房间预检,进入房间前请先调用此方法
* @param sessionInfo 当前房间数据
* @param sceneType scene 类型
*
**/
/** @en
* Precheck before joining the room, call this method before joining room.
* @param sessionInfo session info
* @param sceneType sceneType
*/
checkIn(sessionInfo: EduSessionInfo, sceneType: SceneType, mode?: 'check-in' | 'entry'): Promise<void>;
private _entry;
/**
* 加入子房间
* @param roomUuid 子房间 ID
*
**/
/** @en
* Joins a sub-room
* @param roomUuid The sub-room ID
*/
joinSubRoom(roomUuid: string): Promise<void>;
/**
* 离开子房间
**/
/** @en
* Leaves the sub-room
*/
leaveSubRoom(): Promise<void>;
/**
* 离开房间
* @param reason 原因
*
**/
/** @en
* Leaves the room
* @param reason The reason
*/
leaveClassroom(reason: LeaveReason, promise?: Promise<void>): Promise<void>;
private _clean;
/**
* 加入 RTC 频道
* @param options RTC 配置
*
**/
/** @en
* Joins an RTC channel
* @param options The RTC options
*/
joinRTC(options?: AgoraRteSceneJoinRTCOptions): Promise<void>;
/**
* 离开 RTC 频道
* @param connectionType 大小 scene
*
**/
/** @en
* Leaves the RTC channel
* @param connectionType connection type
*/
leaveRTC(connectionType?: AGRtcConnectionType): Promise<void>;
/**
* 获取房间 RTC 状态
* @param connectionType
* @returns
*
**/
/** @en
* Gets the RTC state
* @param connectionType
* @returns
*/
getRtcState(connectionType: AGRtcConnectionType): AGRtcState;
/**
* 添加一个云代理观察者,joinClassroom 成功调用后才能调用此方法
* @param observer
*/
/** @en
* Adds an observer for cloud proxy, this method can only be called after joinClassroom succeeds
* @param observer
*/
addCloudProxyObserver(observer: AgoraCloudProxyObserver): void;
/**
* 移除一个云代理观察者,joinClassroom 成功调用后才能调用此方法
* @param observer
*/
/** @en
* Removes an observer for cloud proxy, this method can only be called after joinClassroom succeeds
* @param observer
*/
removeCloudProxyObserver(observer: AgoraCloudProxyObserver): void;
private _getClassroomState;
/**
* @internal
*/
/**
* @internal
*/
onInstall(): void;
/**
* @internal
*/
/**
* @internal
*/
onDestroy(): void;
}