diff options
Diffstat (limited to 'src/server/api/stream/index.ts')
| -rw-r--r-- | src/server/api/stream/index.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts index afedd4362c..6d3675c94b 100644 --- a/src/server/api/stream/index.ts +++ b/src/server/api/stream/index.ts @@ -148,7 +148,7 @@ export default class Connection { private onChannelConnectRequested(payload: any) { const { channel, id, params } = payload; log(`CH CONNECT: ${id} ${channel} by @${this.user.username}`); - this.connectChannel(id, params, (channels as any)[channel]); + this.connectChannel(id, params, channel); } /** @@ -177,10 +177,15 @@ export default class Connection { * チャンネルに接続 */ @autobind - public connectChannel(id: string, params: any, channelClass: { new(id: string, connection: Connection): Channel }) { - const channel = new channelClass(id, this); - this.channels.push(channel); - channel.init(params); + public connectChannel(id: string, params: any, channel: string) { + // 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視 + if ((channels as any)[channel].shouldShare && this.channels.some(c => c.chName === channel)) { + return; + } + + const ch: Channel = new (channels as any)[channel](id, this); + this.channels.push(ch); + ch.init(params); this.sendMessageToWs('connected', { id: id }); |