import AgoraRTC from "agora-rtc-sdk-ng"; import { ActionParams } from "../../action/type/ActionParams"; import { Context } from "../../context/Context"; import { CustomError } from "../../exception/CustomError"; import { EOperationStatus } from "../enum/EOperationStatus"; import { EOperationType } from "../enum/EOperationType"; import { IOperation } from "../interface/IOperation"; export class BaseOperation implements IOperation { public type! : EOperationType; public status!: EOperationStatus; public datetime!: Date; public context!: Context; public errors: Array = []; constructor(context: Context){ this.status = EOperationStatus.INIT; this.setContext(context); } public addError(error: any): void { let customError = CustomError.parseCustomError(error); if(customError instanceof Array){ customError.map((itemError)=>{this.errors.push(itemError);}); }else{ this.errors.push(customError); } } public setContext(context: Context): void { this.context = context; } public getContext(): Context { return this.context; } public async handler(params ? : ActionParams) : Promise{ return new Promise( async (resolve, reject)=>{ resolve(this.status); }); } }