From 21eadec6a459d6dec192ccea2a00ea3b600e735a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 15 Jul 2017 16:15:01 -0700 Subject: [PATCH] GUACAMOLE-346: Seek operations should be atomic with respect to the various timeouts. --- .../main/webapp/modules/SessionRecording.js | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/SessionRecording.js b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js index c4279eee5..d54498288 100644 --- a/guacamole-common-js/src/main/webapp/modules/SessionRecording.js +++ b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js @@ -330,36 +330,36 @@ Guacamole.SessionRecording = function SessionRecording(tunnel) { */ var seekToFrame = function seekToFrame(index, callback) { - var startIndex; - // Abort any in-progress seek abortSeek(); - // Back up until startIndex represents current state - for (startIndex = index; startIndex >= 0; startIndex--) { - - var frame = frames[startIndex]; - - // If we've reached the current frame, startIndex represents - // current state by definition - if (startIndex === currentFrame) - break; - - // If frame has associated absolute state, make that frame the - // current state - if (frame.clientState) { - playbackClient.importState(frame.clientState); - break; - } - - } - - // Advance to frame index after current state - startIndex++; - // Replay frames asynchronously seekTimeout = window.setTimeout(function continueSeek() { + var startIndex; + + // Back up until startIndex represents current state + for (startIndex = index; startIndex >= 0; startIndex--) { + + var frame = frames[startIndex]; + + // If we've reached the current frame, startIndex represents + // current state by definition + if (startIndex === currentFrame) + break; + + // If frame has associated absolute state, make that frame the + // current state + if (frame.clientState) { + playbackClient.importState(frame.clientState); + break; + } + + } + + // Advance to frame index after current state + startIndex++; + var startTime = new Date().getTime(); // Replay any applicable incremental frames