mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: await & error handling
This commit is contained in:
parent
90eb3da7f8
commit
b802aad726
@ -61,9 +61,10 @@ export class LaanaWsServerAdapter implements ILaanaNetworkAdapter {
|
|||||||
this.core.context.logger.logError('未实现的动作名', actionName);
|
this.core.context.logger.logError('未实现的动作名', actionName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const ret = actionHandler(data.data.actionPing.ping[actionName]);
|
const ret = await actionHandler(data.data.actionPing.ping[actionName]);
|
||||||
this.checkStateAndReply(LaanaDataWrapper.toBinary({
|
this.checkStateAndReply(LaanaDataWrapper.toBinary({
|
||||||
data: {
|
data: {
|
||||||
oneofKind: 'actionPong',
|
oneofKind: 'actionPong',
|
||||||
@ -74,10 +75,27 @@ export class LaanaWsServerAdapter implements ILaanaNetworkAdapter {
|
|||||||
pong: {
|
pong: {
|
||||||
oneofKind: actionName,
|
oneofKind: actionName,
|
||||||
[actionName]: ret,
|
[actionName]: ret,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}), wsClient);
|
}), wsClient);
|
||||||
|
} catch (e: any) {
|
||||||
|
this.core.context.logger.logError('处理动作时出现错误', e);
|
||||||
|
this.checkStateAndReply(LaanaDataWrapper.toBinary({
|
||||||
|
data: {
|
||||||
|
oneofKind: 'actionPong',
|
||||||
|
actionPong: {
|
||||||
|
clientPingId: data.data.actionPing.clientPingId,
|
||||||
|
pong: {
|
||||||
|
oneofKind: 'failed',
|
||||||
|
failed: {
|
||||||
|
reason: e.toString(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}), wsClient);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.core.context.logger.logWarn('未知的数据包类型', data.data.oneofKind);
|
this.core.context.logger.logWarn('未知的数据包类型', data.data.oneofKind);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user