Merge branch 'master' of https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-client
This commit is contained in:
commit
71645514e5
@ -1 +1 @@
|
||||
Subproject commit e521b07d86e7ac10bc6cb96288ae025b677485f7
|
||||
Subproject commit 91eb4a1d0835a8bc007febaf9054291c27d065ff
|
@ -31,24 +31,27 @@ export interface MessageCliOption {
|
||||
* 认证token
|
||||
*/
|
||||
token?: string;
|
||||
/**
|
||||
* 认证失败处理
|
||||
* @returns
|
||||
*/
|
||||
onAuthenticationFailed?: () => void;
|
||||
/**
|
||||
* 连接成功处理
|
||||
* @param ctx
|
||||
* @returns
|
||||
*/
|
||||
onConnected?: (ctx: unknown) => void;
|
||||
/**
|
||||
* 端口连接处理
|
||||
*/
|
||||
onDisconnected?: (ctx: unknown) => void;
|
||||
reconnectDelay?: number; // 重连延时,默认3秒,设置为0不重连.
|
||||
heartbeatIncoming?: number; // 服务端过来的心跳间隔,默认30秒
|
||||
heartbeatOutgoing?: number; // 到服务端的心跳间隔,默认30秒
|
||||
// /**
|
||||
// * 认证失败处理
|
||||
// * @returns
|
||||
// */
|
||||
// onAuthenticationFailed?: () => void;
|
||||
// /**
|
||||
// * 连接成功处理
|
||||
// * @param ctx
|
||||
// * @returns
|
||||
// */
|
||||
// onConnected?: (ctx: unknown) => void;
|
||||
// /**
|
||||
// * 端口连接处理
|
||||
// */
|
||||
// onDisconnected?: (ctx: unknown) => void;
|
||||
// // 重连延时,默认3秒,设置为0不重连.
|
||||
// reconnectDelay?: number;
|
||||
// // 服务端过来的心跳间隔,默认30秒
|
||||
// heartbeatIncoming?: number;
|
||||
// // 到服务端的心跳间隔,默认30秒
|
||||
// heartbeatOutgoing?: number;
|
||||
}
|
||||
|
||||
const DefaultStompOption: MessageCliOption = {
|
||||
@ -56,9 +59,9 @@ const DefaultStompOption: MessageCliOption = {
|
||||
protocol: 'protobuf',
|
||||
wsUrl: '',
|
||||
token: '',
|
||||
reconnectDelay: 3000,
|
||||
heartbeatIncoming: 30000,
|
||||
heartbeatOutgoing: 30000,
|
||||
// reconnectDelay: 3000,
|
||||
// heartbeatIncoming: 30000,
|
||||
// heartbeatOutgoing: 30000,
|
||||
};
|
||||
|
||||
export interface IMessageClient extends EventEmitter<MessageClientEvents> {
|
||||
@ -69,8 +72,14 @@ export interface IMessageClient extends EventEmitter<MessageClientEvents> {
|
||||
*/
|
||||
subscribe(destination: string, handle: MessageHandler): ISubscription;
|
||||
|
||||
/**
|
||||
* 是否已经连接
|
||||
*/
|
||||
get connected(): boolean;
|
||||
|
||||
/**
|
||||
* 关闭连接
|
||||
*/
|
||||
close(): void;
|
||||
}
|
||||
|
||||
@ -219,6 +228,9 @@ export class AppWsMsgBroker {
|
||||
this.subscriptions.set(sub.destination, sub);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重连后重新订阅
|
||||
*/
|
||||
resubscribe() {
|
||||
this.subscriptions.forEach((record) => {
|
||||
this.subscribe(record);
|
||||
|
@ -6,6 +6,10 @@ import {
|
||||
MessageHandler,
|
||||
} from './BasicMessageClient';
|
||||
|
||||
const ReconnectDelay = 3000;
|
||||
const HeartbeatIncoming = 30000;
|
||||
const HeartbeatOutgoing = 30000;
|
||||
|
||||
export class StompMessagingClient extends MessageClient {
|
||||
options: MessageCliOption;
|
||||
cli: StompClient;
|
||||
@ -17,9 +21,9 @@ export class StompMessagingClient extends MessageClient {
|
||||
connectHeaders: {
|
||||
Authorization: options.token ? options.token : '',
|
||||
},
|
||||
reconnectDelay: options.reconnectDelay,
|
||||
heartbeatIncoming: options.heartbeatIncoming,
|
||||
heartbeatOutgoing: options.heartbeatOutgoing,
|
||||
reconnectDelay: ReconnectDelay,
|
||||
heartbeatIncoming: HeartbeatIncoming,
|
||||
heartbeatOutgoing: HeartbeatOutgoing,
|
||||
});
|
||||
|
||||
this.cli.onConnect = () => {
|
||||
@ -29,6 +33,7 @@ export class StompMessagingClient extends MessageClient {
|
||||
const errMsg = frame.headers['message'];
|
||||
if (errMsg === '401') {
|
||||
console.warn('认证失败,断开WebSocket连接');
|
||||
this.cli.deactivate();
|
||||
} else {
|
||||
console.error('收到Stomp错误消息', frame);
|
||||
}
|
||||
|
32
yarn.lock
32
yarn.lock
@ -195,7 +195,7 @@
|
||||
|
||||
"@pixi/graphics-extras@^7.2.4":
|
||||
version "7.2.4"
|
||||
resolved "https://registry.yarnpkg.com/@pixi/graphics-extras/-/graphics-extras-7.2.4.tgz#72ac967992f239d3671d6e680ac891471619fe07"
|
||||
resolved "https://registry.npmjs.org/@pixi/graphics-extras/-/graphics-extras-7.2.4.tgz"
|
||||
integrity sha512-0yT91yqF3KLiZI/iLRcfcYlTVpkVyWsfGtWEIorZs0eX+/zYx7um7EJ2h7tFORI/1FxA2maR4td5vpgCwOLJAQ==
|
||||
|
||||
"@pixi/graphics@7.2.4":
|
||||
@ -316,27 +316,27 @@
|
||||
|
||||
"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz"
|
||||
integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==
|
||||
|
||||
"@protobufjs/base64@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/base64/-/base64-1.1.2.tgz"
|
||||
integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==
|
||||
|
||||
"@protobufjs/codegen@^2.0.4":
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/codegen/-/codegen-2.0.4.tgz"
|
||||
integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==
|
||||
|
||||
"@protobufjs/eventemitter@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz"
|
||||
integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==
|
||||
|
||||
"@protobufjs/fetch@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/fetch/-/fetch-1.1.0.tgz"
|
||||
integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==
|
||||
dependencies:
|
||||
"@protobufjs/aspromise" "^1.1.1"
|
||||
@ -344,27 +344,27 @@
|
||||
|
||||
"@protobufjs/float@^1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/float/-/float-1.0.2.tgz"
|
||||
integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==
|
||||
|
||||
"@protobufjs/inquire@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/inquire/-/inquire-1.1.0.tgz"
|
||||
integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==
|
||||
|
||||
"@protobufjs/path@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/path/-/path-1.1.2.tgz"
|
||||
integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==
|
||||
|
||||
"@protobufjs/pool@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/pool/-/pool-1.1.0.tgz"
|
||||
integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==
|
||||
|
||||
"@protobufjs/utf8@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
|
||||
resolved "https://registry.npmmirror.com/@protobufjs/utf8/-/utf8-1.1.0.tgz"
|
||||
integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==
|
||||
|
||||
"@quasar/app-vite@^1.0.0":
|
||||
@ -546,7 +546,7 @@
|
||||
|
||||
"@types/node@>=13.7.0":
|
||||
version "20.4.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.5.tgz#9dc0a5cb1ccce4f7a731660935ab70b9c00a5d69"
|
||||
resolved "https://registry.npmmirror.com/@types/node/-/node-20.4.5.tgz"
|
||||
integrity sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==
|
||||
|
||||
"@types/node@^12.20.21":
|
||||
@ -1049,7 +1049,7 @@ caniuse-lite@^1.0.30001464, caniuse-lite@^1.0.30001489:
|
||||
|
||||
centrifuge@^4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/centrifuge/-/centrifuge-4.0.1.tgz#2607756d4b7da6201ca12666bfc6564e4e8ef6a2"
|
||||
resolved "https://registry.npmmirror.com/centrifuge/-/centrifuge-4.0.1.tgz"
|
||||
integrity sha512-akAyUfvMnyoCa6X2tdU5WPEccVqjkb9R/xxfm3iJ7ha7EIawjKu1dQmoyMkoLDpgl0jFxhorjmVgRcbojE17DA==
|
||||
dependencies:
|
||||
events "^3.3.0"
|
||||
@ -1776,7 +1776,7 @@ eventemitter3@^4.0.0:
|
||||
|
||||
events@^3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400"
|
||||
resolved "https://registry.npmmirror.com/events/-/events-3.3.0.tgz"
|
||||
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==
|
||||
|
||||
express@^4.17.3:
|
||||
@ -2389,7 +2389,7 @@ log-symbols@^4.1.0:
|
||||
|
||||
long@^5.0.0:
|
||||
version "5.2.3"
|
||||
resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1"
|
||||
resolved "https://registry.npmmirror.com/long/-/long-5.2.3.tgz"
|
||||
integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==
|
||||
|
||||
lower-case@^1.1.1:
|
||||
@ -2782,7 +2782,7 @@ process-nextick-args@~2.0.0:
|
||||
|
||||
protobufjs@^7.2.4:
|
||||
version "7.2.4"
|
||||
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.4.tgz#3fc1ec0cdc89dd91aef9ba6037ba07408485c3ae"
|
||||
resolved "https://registry.npmmirror.com/protobufjs/-/protobufjs-7.2.4.tgz"
|
||||
integrity sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ==
|
||||
dependencies:
|
||||
"@protobufjs/aspromise" "^1.1.2"
|
||||
|
Loading…
Reference in New Issue
Block a user