This commit is contained in:
syuilo
2021-05-23 13:34:36 +09:00
parent ca655c0628
commit 6ae5f76250
4 changed files with 30 additions and 27 deletions

View File

@@ -114,6 +114,15 @@ export default class Stream extends EventEmitter<StreamEvents> {
this.stream.addEventListener('message', this.onMessage);
}
@autobind
public useChannel<C extends keyof ChannelDef>(channel: C, params?: any): Connection<ChannelDef[C]['events']> {
if (params) {
return this.connectToChannel(channel, params);
} else {
return this.useSharedConnection(channel);
}
}
@autobind
public useSharedConnection<C extends keyof ChannelDef>(channel: C, name?: string): SharedConnection<ChannelDef[C]['events']> {
let pool = this.sharedConnectionPools.find(p => p.channel === channel);