From dff9c7ac486ee10fde3392cb982f807126bcf312 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 11 Oct 2018 21:25:55 +0900 Subject: [PATCH] Clean up and fix --- src/client/app/common/scripts/stream.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/client/app/common/scripts/stream.ts b/src/client/app/common/scripts/stream.ts index 2ff3975d5f..b866baba78 100644 --- a/src/client/app/common/scripts/stream.ts +++ b/src/client/app/common/scripts/stream.ts @@ -10,7 +10,6 @@ import MiOS from '../../mios'; export default class Stream extends EventEmitter { private stream: ReconnectingWebsocket; private state: string; - private buffer: any[]; private sharedConnectionPools: Pool[] = []; private sharedConnections: SharedConnection[] = []; private nonSharedConnections: NonSharedConnection[] = []; @@ -19,7 +18,6 @@ export default class Stream extends EventEmitter { super(); this.state = 'initializing'; - this.buffer = []; const user = os.store.state.i; @@ -70,17 +68,12 @@ export default class Stream extends EventEmitter { this.state = 'connected'; this.emit('_connected_'); - // バッファーを処理 - const _buffer = [].concat(this.buffer); // Shallow copy - this.buffer = []; // Clear buffer - _buffer.forEach(data => { - this.send(data); // Resend each buffered messages - }); - // チャンネル再接続 if (isReconnect) { this.sharedConnectionPools.forEach(p => { - p.connect(); + if (p.users > 0) { + p.connect(); + } }); this.nonSharedConnections.forEach(c => { c.connect(); @@ -133,12 +126,6 @@ export default class Stream extends EventEmitter { body: payload }; - // まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する - if (this.state != 'connected') { - this.buffer.push(data); - return; - } - this.stream.send(JSON.stringify(data)); } @@ -156,7 +143,7 @@ class Pool { public channel: string; public id: string; protected stream: Stream; - private users = 0; + public users = 0; private disposeTimerId: any; private isConnected = false;