瀏覽代碼

Properly process outgoing message queue

It's a queue, not a stack 🤦

Furthermore, modifying the array while iterating over it might be
problematic.
Danilo Bargen 7 年之前
父節點
當前提交
9ff1c5d766
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      src/services/webclient.ts

+ 7 - 2
src/services/webclient.ts

@@ -571,8 +571,13 @@ export class WebClientService {
         // Process pending messages
         if (this.outgoingMessageQueue.length > 0) {
             this.$log.debug(this.logTag, 'Sending', this.outgoingMessageQueue.length, 'pending messages');
-            for (const _ of this.outgoingMessageQueue.keys()) {
-                this.send(this.outgoingMessageQueue.pop());
+            while (true) {
+                const msg = this.outgoingMessageQueue.shift();
+                if (msg === undefined) {
+                    break;
+                } else {
+                    this.send(msg);
+                }
             }
         }
     }