Commit 7340e81b authored by Chunchi Che's avatar Chunchi Che

optimize service

parent 89404ad6
Pipeline #23188 passed with stages
in 9 minutes and 51 seconds
...@@ -88,13 +88,9 @@ const ReplayIgnoreMsg = [ ...@@ -88,13 +88,9 @@ const ReplayIgnoreMsg = [
"announce", "announce",
]; ];
let animation: Promise<unknown> = new Promise<void>((rs) => rs()); export default async function handleGameMsg(
pb: ygopro.YgoStocMsg,
export default async function handleGameMsg(pb: ygopro.YgoStocMsg) { ): Promise<void> {
animation = animation.then(() => _handleGameMsg(pb));
}
async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
const msg = pb.stoc_game_msg; const msg = pb.stoc_game_msg;
if (ActiveList.includes(msg.gameMsg)) { if (ActiveList.includes(msg.gameMsg)) {
......
...@@ -28,7 +28,15 @@ import { handleWaitingSide } from "./side/waitingSide"; ...@@ -28,7 +28,15 @@ import { handleWaitingSide } from "./side/waitingSide";
* 然后再分发到各个处理函数中去处理。 * 然后再分发到各个处理函数中去处理。
* *
* */ * */
let animation: Promise<void> = Promise.resolve();
export default async function handleSocketMessage(e: MessageEvent) { export default async function handleSocketMessage(e: MessageEvent) {
// 确保按序执行
animation = animation.then(() => _handle(e));
}
async function _handle(e: MessageEvent) {
const packet = YgoProPacket.deserialize(e.data); const packet = YgoProPacket.deserialize(e.data);
const pb = adaptStoc(packet); const pb = adaptStoc(packet);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment