Commit ae9a6913 authored by Chunchi Che's avatar Chunchi Che

fix handleSocketMessage

parent 94b7862d
Pipeline #23661 passed with stages
in 15 minutes and 16 seconds
...@@ -40,90 +40,88 @@ export default async function handleSocketMessage(e: MessageEvent) { ...@@ -40,90 +40,88 @@ export default async function handleSocketMessage(e: MessageEvent) {
async function _handle(e: MessageEvent) { async function _handle(e: MessageEvent) {
const packets = YgoProPacket.deserialize(e.data); const packets = YgoProPacket.deserialize(e.data);
await Promise.all( for (const packet of packets) {
packets.map(async (packet) => { const pb = adaptStoc(packet);
const pb = adaptStoc(packet);
switch (pb.msg) { switch (pb.msg) {
case "stoc_join_game": { case "stoc_join_game": {
handleJoinGame(pb); handleJoinGame(pb);
break; break;
} }
case "stoc_chat": { case "stoc_chat": {
handleChat(pb); handleChat(pb);
break; break;
} }
case "stoc_hs_player_change": { case "stoc_hs_player_change": {
handleHsPlayerChange(pb); handleHsPlayerChange(pb);
break; break;
} }
case "stoc_hs_watch_change": { case "stoc_hs_watch_change": {
handleHsWatchChange(pb); handleHsWatchChange(pb);
break; break;
} }
case "stoc_hs_player_enter": { case "stoc_hs_player_enter": {
handleHsPlayerEnter(pb); handleHsPlayerEnter(pb);
break; break;
} }
case "stoc_type_change": { case "stoc_type_change": {
handleTypeChange(pb); handleTypeChange(pb);
break; break;
} }
case "stoc_select_hand": { case "stoc_select_hand": {
handleSelectHand(pb); handleSelectHand(pb);
break; break;
} }
case "stoc_hand_result": { case "stoc_hand_result": {
handleHandResult(pb); handleHandResult(pb);
break; break;
} }
case "stoc_select_tp": { case "stoc_select_tp": {
handleSelectTp(pb); handleSelectTp(pb);
break; break;
} }
case "stoc_deck_count": { case "stoc_deck_count": {
handleDeckCount(pb); handleDeckCount(pb);
break; break;
} }
case "stoc_duel_start": { case "stoc_duel_start": {
handleDuelStart(pb); handleDuelStart(pb);
break; break;
} }
case "stoc_duel_end": { case "stoc_duel_end": {
handleDuelEnd(pb); handleDuelEnd(pb);
break; break;
}
case "stoc_game_msg": {
if (!replayStore.isReplay) {
// 如果不是回放模式,则记录回放数据
replayStore.record(packet);
} }
case "stoc_game_msg": { await handleGameMsg(pb);
if (!replayStore.isReplay) {
// 如果不是回放模式,则记录回放数据
replayStore.record(packet);
}
await handleGameMsg(pb);
break; break;
} }
case "stoc_time_limit": { case "stoc_time_limit": {
handleTimeLimit(pb.stoc_time_limit); handleTimeLimit(pb.stoc_time_limit);
break; break;
} }
case "stoc_error_msg": { case "stoc_error_msg": {
await handleErrorMsg(pb.stoc_error_msg); await handleErrorMsg(pb.stoc_error_msg);
break; break;
} }
case "stoc_change_side": { case "stoc_change_side": {
handleChangeSide(pb.stoc_change_side); handleChangeSide(pb.stoc_change_side);
break; break;
} }
case "stoc_waiting_side": { case "stoc_waiting_side": {
handleWaitingSide(pb.stoc_waiting_side); handleWaitingSide(pb.stoc_waiting_side);
break; break;
} }
default: { default: {
console.log(packet); console.log(packet);
break; break;
}
} }
}), }
); }
} }
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