添加一些注释,清理暂时不用的配置项
This commit is contained in:
parent
e521b07d86
commit
0562fb08b2
@ -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 = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user