Commit 992b8979 authored by Chunchi Che's avatar Chunchi Che

update small

parent 5220b672
Pipeline #22097 passed with stages
in 18 minutes and 59 seconds
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
// //
// 因此封装了一个`WebSocketStream`类,当每次Websocket连接中有消息到达时,往流中添加event, // 因此封装了一个`WebSocketStream`类,当每次Websocket连接中有消息到达时,往流中添加event,
// 同时执行器会不断地从流中获取event进行处理。 // 同时执行器会不断地从流中获取event进行处理。
import { sleep } from "./sleep";
const SLEEP_INTERVAL = 200;
export class WebSocketStream { export class WebSocketStream {
public ws: WebSocket; public ws: WebSocket;
stream: ReadableStream; stream: ReadableStream;
...@@ -52,9 +48,7 @@ export class WebSocketStream { ...@@ -52,9 +48,7 @@ export class WebSocketStream {
return; return;
} else { } else {
// websocket not closed, sleep sometime, wait for next message from server // websocket not closed, handle next message from server
await sleep(SLEEP_INTERVAL);
return reader.read().then(process); return reader.read().then(process);
} }
} }
......
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import { sleep } from "@/infra";
import { cardStore, fetchEsHintMeta, matStore } from "@/stores"; import { cardStore, fetchEsHintMeta, matStore } from "@/stores";
export default async (attack: ygopro.StocGameMessage.MsgAttack) => { export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
...@@ -18,7 +17,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => { ...@@ -18,7 +17,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
if (attack.direct_attack) { if (attack.direct_attack) {
attacker.directAttack = true; attacker.directAttack = true;
await sleep(500); // await sleep(500);
attacker.directAttack = false; attacker.directAttack = false;
} else { } else {
const target = cardStore.at( const target = cardStore.at(
...@@ -33,7 +32,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => { ...@@ -33,7 +32,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
...target, ...target,
}; };
await sleep(500); // await sleep(500);
attacker.attackTarget = undefined; attacker.attackTarget = undefined;
} }
} }
......
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import { useConfig } from "@/config"; import { eventbus, Task } from "@/infra";
import { eventbus, sleep, Task } from "@/infra";
import { cardStore, fetchEsHintMeta, matStore } from "@/stores"; import { cardStore, fetchEsHintMeta, matStore } from "@/stores";
export default async (chaining: ygopro.StocGameMessage.MsgChaining) => { export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
...@@ -11,7 +10,6 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => { ...@@ -11,7 +10,6 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
await cardStore.setChaining(chaining.location, chaining.code, true); await cardStore.setChaining(chaining.location, chaining.code, true);
await sleep(useConfig().ui.chainingDelay);
const location = chaining.location; const location = chaining.location;
// 恢复成非`chaining`状态 // 恢复成非`chaining`状态
......
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