summaryrefslogtreecommitdiff
path: root/src/client/app/common/scripts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-10-11 22:17:27 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-10-11 22:17:27 +0900
commit5df0e102fde19706e222bff621d1f71a6fb77656 (patch)
tree7e6c03a2fd9cefb188cd69a9d83953a67c575adb /src/client/app/common/scripts
parent10.9.0 (diff)
downloadsharkey-5df0e102fde19706e222bff621d1f71a6fb77656.tar.gz
sharkey-5df0e102fde19706e222bff621d1f71a6fb77656.tar.bz2
sharkey-5df0e102fde19706e222bff621d1f71a6fb77656.zip
Fix
Diffstat (limited to 'src/client/app/common/scripts')
-rw-r--r--src/client/app/common/scripts/stream.ts21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/client/app/common/scripts/stream.ts b/src/client/app/common/scripts/stream.ts
index b866baba78..3fbfa4b631 100644
--- a/src/client/app/common/scripts/stream.ts
+++ b/src/client/app/common/scripts/stream.ts
@@ -47,6 +47,11 @@ export default class Stream extends EventEmitter {
}
@autobind
+ public removeSharedConnectionPool(pool: Pool) {
+ this.sharedConnectionPools = this.sharedConnectionPools.filter(p => p !== pool);
+ }
+
+ @autobind
public connectToChannel(channel: string, params?: any): NonSharedConnection {
const connection = new NonSharedConnection(this, channel, params);
this.nonSharedConnections.push(connection);
@@ -71,9 +76,7 @@ export default class Stream extends EventEmitter {
// チャンネル再接続
if (isReconnect) {
this.sharedConnectionPools.forEach(p => {
- if (p.users > 0) {
- p.connect();
- }
+ p.connect();
});
this.nonSharedConnections.forEach(c => {
c.connect();
@@ -152,6 +155,13 @@ class Pool {
this.stream = stream;
this.id = Math.random().toString();
+
+ this.stream.on('_disconnected_', this.onStreamDisconnected);
+ }
+
+ @autobind
+ private onStreamDisconnected() {
+ this.isConnected = false;
}
@autobind
@@ -185,6 +195,7 @@ class Pool {
@autobind
public connect() {
+ if (this.isConnected) return;
this.isConnected = true;
this.stream.send('connect', {
channel: this.channel,
@@ -194,9 +205,9 @@ class Pool {
@autobind
private disconnect() {
- this.isConnected = false;
- this.disposeTimerId = null;
+ this.stream.off('_disconnected_', this.onStreamDisconnected);
this.stream.send('disconnect', { id: this.id });
+ this.stream.removeSharedConnectionPool(this);
}
}