(data)
| 207 | this.cmd = cmd; |
| 208 | } |
| 209 | request(data) { |
| 210 | if (SERVER_CONNECTION == true) { |
| 211 | return; |
| 212 | } |
| 213 | SERVER_CONNECTION = true; |
| 214 | console.log(data); |
| 215 | if (this.cmd != "updateLog") { |
| 216 | UNDO = new Object(); |
| 217 | } |
| 218 | // Prepare the request data |
| 219 | data["cmd"] = this.cmd; |
| 220 | const requestData = JSON.stringify(data); |
| 221 | // Use existing WebSocket connection |
| 222 | if (globalWS && globalWS.readyState === WebSocket.OPEN) { |
| 223 | globalWS.send(requestData); |
| 224 | } |
| 225 | else { |
| 226 | // Initialize connection if not available |
| 227 | initWebSocket(); |
| 228 | // Add to pending requests queue |
| 229 | pendingRequests.push({ cmd: this.cmd, data: data }); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | // Initialize WebSocket connection when the page loads |
| 234 | document.addEventListener('DOMContentLoaded', function () { |
no test coverage detected