Skip to content

Commit

Permalink
fix: duplicated flush event on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
mind-ar committed Mar 15, 2024
1 parent bcf4129 commit 8748991
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export const eventsFor = (io: Server, interpreter: Interpreter, dynamicDiagramCl
const sizeCanvas = canvasResolution(interpreter)
io.on('connection', socket => {
logger.info(successDescription('Running game!'))
socket.on('disconnect', () => { logger.info(successDescription('Game finished')) })
socket.on('keyPressed', key => {
queueEvent(interpreter, buildKeyPressEvent(interpreter, wKeyCode(key.key, key.keyCode)), buildKeyPressEvent(interpreter, 'ANY'))
})
Expand All @@ -221,6 +220,12 @@ export const eventsFor = (io: Server, interpreter: Interpreter, dynamicDiagramCl
clearInterval(id)
}
}, 100)

socket.on('disconnect', () => {
clearInterval(id)
logger.info(successDescription('Game finished'))

Check warning on line 226 in src/commands/run.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/run.ts#L224-L226

Added lines #L224 - L226 were not covered by tests
})

})
}

Expand Down

0 comments on commit 8748991

Please sign in to comment.