add isScreenshotWaiting var

This commit is contained in:
Simon Vieille 2022-04-13 16:08:39 +02:00
parent fc56154edb
commit 506dc259ca
Signed by: deblan
GPG key ID: 03383D15A1D31745

View file

@ -3,6 +3,7 @@ var $pointer, $scroller, $response, $screenshotImg;
var scrollLastTimestamp, scrollLastValue;
var mousePosX, mousePosY, mouseInitPosX, mouseInitPosY;
var isLive = false;
var isScreenshotWaiting = false;
var createWebSocketConnection = function() {
ws = new WebSocket('ws://' + window.location.hostname + ':14598');
@ -28,6 +29,7 @@ var createWebSocketConnection = function() {
$response.fadeOut();
}, 2500);
} else if (data.type === 'screenshot') {
isScreenshotWaiting = false
$screenshotImg.attr('src', 'data:image/png;base64, ' + data.value);
}
}
@ -209,7 +211,10 @@ var liveClickHandler = function(e, quality) {
var doScreenshot = function() {
if (isLive) {
ws.send(`{"type":"screenshot","quality":"${quality}"}`);
if (!isScreenshotWaiting) {
isScreenshotWaiting = true
ws.send(`{"type":"screenshot","quality":"${quality}"}`);
}
window.setTimeout(doScreenshot, 100);
}