bugfix-修改Centrifuge订阅处理逻辑

This commit is contained in:
walker 2023-08-01 18:33:26 +08:00
parent d7379d4406
commit 4e8135b471

View File

@ -49,7 +49,9 @@ export class CentrifugeMessagingClient extends MessageClient {
}
subscribe(destination: string, handle: MessageHandler): ISubscription {
const sub = this.cli.newSubscription(destination);
let sub = this.cli.getSubscription(destination);
if (!sub) {
sub = this.cli.newSubscription(destination);
sub
.on('publication', (ctx) => {
if (this.options.protocol === 'json') {
@ -65,6 +67,9 @@ export class CentrifugeMessagingClient extends MessageClient {
console.log('订阅centrifuge服务消息成功', destination, ctx);
})
.subscribe();
} else {
sub.subscribe();
}
return sub;
}