共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視するように
This commit is contained in:
@ -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
|
||||
});
|
||||
|
Reference in New Issue
Block a user