Clean up and fix
This commit is contained in:
parent
3a80b59986
commit
dff9c7ac48
|
@ -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 => {
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue