From d7379d4406889053bdf764eff8cd83779bb9d751 Mon Sep 17 00:00:00 2001 From: walker Date: Mon, 31 Jul 2023 16:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=BC=E5=85=A5=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jlgraphic/message/CentrifugeBroker.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jlgraphic/message/CentrifugeBroker.ts b/src/jlgraphic/message/CentrifugeBroker.ts index 6c6122c..dd7e746 100644 --- a/src/jlgraphic/message/CentrifugeBroker.ts +++ b/src/jlgraphic/message/CentrifugeBroker.ts @@ -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);