From c415c76ac632b8e55cf0260c52ebc7c77836614e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 9 Jun 2020 08:10:11 -0700 Subject: [PATCH] Don't let a new prompt get started when another is active This avoids any negative side effect from a race condition where two clients request a game to start within a short time window of each other. When one prompt is active, the server will ignore any further incoming requests to start a new prompt, (until the active one is completed). --- empathy.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/empathy.js b/empathy.js index 8ecf9e1..29d31bf 100644 --- a/empathy.js +++ b/empathy.js @@ -43,6 +43,11 @@ class Empathy extends Game { if (! prompt) return false; + /* Ignore any start request that comes in while a prompt is + * already being played. */ + if (this.state.active_prompt) + return false; + this.state.active_prompt = prompt; this.broadcast_event_object('start', prompt); -- 2.43.0