bugfix-修改Centrifuge订阅处理逻辑
This commit is contained in:
parent
d7379d4406
commit
4e8135b471
@ -49,22 +49,27 @@ export class CentrifugeMessagingClient extends MessageClient {
|
||||
}
|
||||
|
||||
subscribe(destination: string, handle: MessageHandler): ISubscription {
|
||||
const sub = this.cli.newSubscription(destination);
|
||||
sub
|
||||
.on('publication', (ctx) => {
|
||||
if (this.options.protocol === 'json') {
|
||||
console.log('收到centrifuge消息:', ctx.data);
|
||||
}
|
||||
try {
|
||||
handle(ctx.data);
|
||||
} catch (error) {
|
||||
console.log('websocket状态消息处理异常', error);
|
||||
}
|
||||
})
|
||||
.on('subscribed', (ctx) => {
|
||||
console.log('订阅centrifuge服务消息成功', destination, ctx);
|
||||
})
|
||||
.subscribe();
|
||||
let sub = this.cli.getSubscription(destination);
|
||||
if (!sub) {
|
||||
sub = this.cli.newSubscription(destination);
|
||||
sub
|
||||
.on('publication', (ctx) => {
|
||||
if (this.options.protocol === 'json') {
|
||||
console.log('收到centrifuge消息:', ctx.data);
|
||||
}
|
||||
try {
|
||||
handle(ctx.data);
|
||||
} catch (error) {
|
||||
console.log('websocket状态消息处理异常', error);
|
||||
}
|
||||
})
|
||||
.on('subscribed', (ctx) => {
|
||||
console.log('订阅centrifuge服务消息成功', destination, ctx);
|
||||
})
|
||||
.subscribe();
|
||||
} else {
|
||||
sub.subscribe();
|
||||
}
|
||||
return sub;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user