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 {
|
subscribe(destination: string, handle: MessageHandler): ISubscription {
|
||||||
const sub = this.cli.newSubscription(destination);
|
let sub = this.cli.getSubscription(destination);
|
||||||
sub
|
if (!sub) {
|
||||||
.on('publication', (ctx) => {
|
sub = this.cli.newSubscription(destination);
|
||||||
if (this.options.protocol === 'json') {
|
sub
|
||||||
console.log('收到centrifuge消息:', ctx.data);
|
.on('publication', (ctx) => {
|
||||||
}
|
if (this.options.protocol === 'json') {
|
||||||
try {
|
console.log('收到centrifuge消息:', ctx.data);
|
||||||
handle(ctx.data);
|
}
|
||||||
} catch (error) {
|
try {
|
||||||
console.log('websocket状态消息处理异常', error);
|
handle(ctx.data);
|
||||||
}
|
} catch (error) {
|
||||||
})
|
console.log('websocket状态消息处理异常', error);
|
||||||
.on('subscribed', (ctx) => {
|
}
|
||||||
console.log('订阅centrifuge服务消息成功', destination, ctx);
|
})
|
||||||
})
|
.on('subscribed', (ctx) => {
|
||||||
.subscribe();
|
console.log('订阅centrifuge服务消息成功', destination, ctx);
|
||||||
|
})
|
||||||
|
.subscribe();
|
||||||
|
} else {
|
||||||
|
sub.subscribe();
|
||||||
|
}
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user