mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 19:14:43 +02:00
Code review
This commit is contained in:
parent
021c3dff32
commit
f74e29e4b0
1 changed files with 12 additions and 7 deletions
|
@ -368,16 +368,21 @@
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
function sendHeartbeat(isOneShot) {
|
function sendHeartbeat() {
|
||||||
Messages.sendMessage(HIFI_RECORDER_CHANNEL, JSON.stringify({
|
Messages.sendMessage(HIFI_RECORDER_CHANNEL, JSON.stringify({
|
||||||
playing: Player.isPlaying(),
|
playing: Player.isPlaying(),
|
||||||
recording: Player.recording(),
|
recording: Player.recording(),
|
||||||
entity: Entity.id()
|
entity: Entity.id()
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
if (!isOneShot) {
|
function onHeartbeatTimer() {
|
||||||
heartbeatTimer = Script.setTimeout(sendHeartbeat, HEARTBEAT_INTERVAL);
|
sendHeartbeat();
|
||||||
}
|
heartbeatTimer = Script.setTimeout(onHeartbeatTimer, HEARTBEAT_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startHeartbeat() {
|
||||||
|
onHeartbeatTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopHeartbeat() {
|
function stopHeartbeat() {
|
||||||
|
@ -401,12 +406,12 @@
|
||||||
} else {
|
} else {
|
||||||
log("Didn't start playing " + message.recording + " because already playing " + Player.recording());
|
log("Didn't start playing " + message.recording + " because already playing " + Player.recording());
|
||||||
}
|
}
|
||||||
sendHeartbeat(true);
|
sendHeartbeat();
|
||||||
break;
|
break;
|
||||||
case PLAYER_COMMAND_STOP:
|
case PLAYER_COMMAND_STOP:
|
||||||
Player.stop();
|
Player.stop();
|
||||||
Player.autoPlay(); // There may be another recording to play.
|
Player.autoPlay(); // There may be another recording to play.
|
||||||
sendHeartbeat(true);
|
sendHeartbeat();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +426,7 @@
|
||||||
Messages.subscribe(HIFI_PLAYER_CHANNEL);
|
Messages.subscribe(HIFI_PLAYER_CHANNEL);
|
||||||
|
|
||||||
Player.autoPlay();
|
Player.autoPlay();
|
||||||
sendHeartbeat();
|
startHeartbeat();
|
||||||
|
|
||||||
UserActivityLogger.logAction("playRecordingAC_script_load");
|
UserActivityLogger.logAction("playRecordingAC_script_load");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue