(data: Object)
| 237 | } |
| 238 | |
| 239 | request(data: Object): any { |
| 240 | if (SERVER_CONNECTION == true) { |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | SERVER_CONNECTION = true; |
| 245 | |
| 246 | console.log(data); |
| 247 | if (this.cmd != "updateLog") { |
| 248 | UNDO = new Object(); |
| 249 | } |
| 250 | |
| 251 | // Prepare the request data |
| 252 | data["cmd"] = this.cmd; |
| 253 | const requestData = JSON.stringify(data); |
| 254 | |
| 255 | // Use existing WebSocket connection |
| 256 | if (globalWS && globalWS.readyState === WebSocket.OPEN) { |
| 257 | globalWS.send(requestData); |
| 258 | } else { |
| 259 | // Initialize connection if not available |
| 260 | initWebSocket(); |
| 261 | // Add to pending requests queue |
| 262 | pendingRequests.push({cmd: this.cmd, data: data}); |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // Initialize WebSocket connection when the page loads |
no test coverage detected