diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-11 21:25:55 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-11 21:25:55 +0900 |
| commit | dff9c7ac486ee10fde3392cb982f807126bcf312 (patch) | |
| tree | f7e884f1604ad049fe3ada43f1142635e90f3947 /src/client/app/common/scripts | |
| parent | 並列に処理するように (diff) | |
| download | sharkey-dff9c7ac486ee10fde3392cb982f807126bcf312.tar.gz sharkey-dff9c7ac486ee10fde3392cb982f807126bcf312.tar.bz2 sharkey-dff9c7ac486ee10fde3392cb982f807126bcf312.zip | |
Clean up and fix
Diffstat (limited to 'src/client/app/common/scripts')
| -rw-r--r-- | src/client/app/common/scripts/stream.ts | 21 |
1 files 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; |