调整导入

添加消息处理异常捕获
This commit is contained in:
walker 2023-07-31 16:55:18 +08:00
parent 91eb4a1d08
commit d7379d4406

View File

@ -1,5 +1,5 @@
import { Centrifuge, State } from 'centrifuge';
import CentrifugeProtobuf from 'centrifuge/build/protobuf';
import { State } from 'centrifuge';
import Centrifuge from 'centrifuge/build/protobuf';
import { MessageCliOption } from './MessageBroker';
import {
ISubscription,
@ -19,7 +19,7 @@ export class CentrifugeMessagingClient extends MessageClient {
protocol: options.protocol,
});
} else {
this.cli = new CentrifugeProtobuf(options.wsUrl, {
this.cli = new Centrifuge(options.wsUrl, {
token: options.token,
protocol: options.protocol,
});
@ -55,7 +55,11 @@ export class CentrifugeMessagingClient extends MessageClient {
if (this.options.protocol === 'json') {
console.log('收到centrifuge消息:', ctx.data);
}
handle(ctx.data);
try {
handle(ctx.data);
} catch (error) {
console.log('websocket状态消息处理异常', error);
}
})
.on('subscribed', (ctx) => {
console.log('订阅centrifuge服务消息成功', destination, ctx);