File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @bytetrade/core" ,
3- "version" : " 0.3.84 " ,
3+ "version" : " 0.3.85 " ,
44 "description" : " didvault core module" ,
55 "main" : " ./dist/index.js" ,
66 "types" : " ./dist/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -10,13 +10,15 @@ export class WebSocketHeart implements IWebSocketHeart {
1010 heartGapTime : number ;
1111 failNum = 0 ;
1212 heartFailNum : number ;
13+ heartRes ?: ( ev : any ) => boolean ;
1314
1415 constructor ( websocketbean : IWebSocketBean ) {
1516 this . websocketbean = websocketbean ;
1617 this . heartSend = this . websocketbean . param . heartSend ?? 'heartSend' ;
1718 this . heartGet = this . websocketbean . param . heartGet ?? 'heartGet' ;
1819 this . heartGapTime = this . websocketbean . param . heartGapTime ?? 30000 ;
1920 this . heartFailNum = this . websocketbean . param . heartFailNum ?? 10 ;
21+ this . heartRes = this . websocketbean . param . heartRes ;
2022 }
2123
2224 timer : number = null as any ;
@@ -52,6 +54,12 @@ export class WebSocketHeart implements IWebSocketHeart {
5254 * @param ev - The received message.
5355 */
5456 onmessage = ( ev : any ) => {
57+ if ( this . heartRes ) {
58+ if ( this . heartRes ( ev ) ) {
59+ this . failNum = 0 ;
60+ }
61+ return ;
62+ }
5563 const messagePrefix = this . websocketbean . param . messagePrefix ?? '' ;
5664 const messageSuffix = this . websocketbean . param . messageSuffix ?? '' ;
5765 const heartGetMessage = messagePrefix + this . heartGet + messageSuffix ;
Original file line number Diff line number Diff line change @@ -220,6 +220,8 @@ export interface IWebSocketHeart {
220220 * @returns
221221 */
222222 onmessage : ( ev : any ) => any ;
223+
224+ heartRes : ( ev : any ) => boolean ;
223225}
224226
225227/**
You can’t perform that action at this time.
0 commit comments