feat: msg push

This commit is contained in:
手瓜一十雪 committed 2024-11-14 20:18:19 +08:00
1 parent a0a50755d3
commit 4487db4e0a
15 files changed
+345 -245

No files matched your search

+5 -5
View File
@@ -37,13 +37,13 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
};
}
public async handle(payload: PayloadType): Promise<OB11Return<ReturnDataType | null>> {
public async handle(payload: PayloadType, adaptername: string): Promise<OB11Return<ReturnDataType | null>> {
const result = await this.check(payload);
if (!result.valid) {
return OB11Response.error(result.message, 400);
}
try {
const resData = await this._handle(payload);
const resData = await this._handle(payload, adaptername);
return OB11Response.ok(resData);
} catch (e: any) {
this.core.context.logger.logError.bind(this.core.context.logger)('发生错误', e);
@@ -51,13 +51,13 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
}
}
public async websocketHandle(payload: PayloadType, echo: any): Promise<OB11Return<ReturnDataType | null>> {
public async websocketHandle(payload: PayloadType, echo: any, adaptername: string): Promise<OB11Return<ReturnDataType | null>> {
const result = await this.check(payload);
if (!result.valid) {
return OB11Response.error(result.message, 1400, echo);
}
try {
const resData = await this._handle(payload);
const resData = await this._handle(payload, adaptername);
return OB11Response.ok(resData, echo);
} catch (e: any) {
this.core.context.logger.logError.bind(this.core.context.logger)('发生错误', e);
@@ -65,7 +65,7 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
}
}
abstract _handle(payload: PayloadType): PromiseLike<ReturnDataType>;
abstract _handle(payload: PayloadType, adaptername: string): PromiseLike<ReturnDataType>;
}
export default BaseAction;