From a7cc58245993bfdc3c3cbd6c0b3e54a610fb3711 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 10 May 2017 10:32:43 +1200 Subject: [PATCH] Don't multiply heartbeats --- scripts/system/playRecordingAC.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/system/playRecordingAC.js b/scripts/system/playRecordingAC.js index b4fae9a2e3..6c7a5eb8b1 100644 --- a/scripts/system/playRecordingAC.js +++ b/scripts/system/playRecordingAC.js @@ -368,13 +368,16 @@ }; }()); - function sendHeartbeat() { + function sendHeartbeat(isOneShot) { Messages.sendMessage(HIFI_RECORDER_CHANNEL, JSON.stringify({ playing: Player.isPlaying(), recording: Player.recording(), entity: Entity.id() })); - heartbeatTimer = Script.setTimeout(sendHeartbeat, HEARTBEAT_INTERVAL); + + if (!isOneShot) { + heartbeatTimer = Script.setTimeout(sendHeartbeat, HEARTBEAT_INTERVAL); + } } function stopHeartbeat() { @@ -398,12 +401,12 @@ } else { log("Didn't start playing " + message.recording + " because already playing " + Player.recording()); } - sendHeartbeat(); + sendHeartbeat(true); break; case PLAYER_COMMAND_STOP: Player.stop(); Player.autoPlay(); // There may be another recording to play. - sendHeartbeat(); + sendHeartbeat(true); break; } }