let pollingServer = false;
let connectionStopped = false;
+ let currentMessageId = 1;
+ const waitingMsgs = [];
+
let serverVersion = 0;
// HTTP path url prefix for any socket (xhr,ess or ws) from browser to server access
function dragTileBegin(e) {
preventDefault(e);
- if (blockMove) {
+ if (blockMove || waitingMsgs.length) {
return;
}
return;
}
+ if (data.id) {
+ const pos = waitingMsgs.indexOf(data.id);
+ if (pos !== -1) {
+ waitingMsgs.splice(pos, 1);
+ }
+ }
+
if (data.version) {
serverVersion = data.version;
}
function sendCmds(cmds) {
if (webSocket && webSocket.readyState === 1) {
+ if (serverVersion >= 202004281800) {
+ for (const cmd of cmds) {
+ waitingMsgs.push(currentMessageId);
+ cmd.id = currentMessageId++;
+ }
+ }
+
webSocket.send(JSON.stringify(cmds));
return;
}
function bagClicked(e) {
preventDefault(e);
- if (blockMove) {
+ if (blockMove || waitingMsgs.length) {
return;
}