@@ -10,6 +10,7 @@ var livedata = "wss://ws-reader.v2.sondehub.org/";
1010var clientID = "SondeHub-Tracker-" + Math . floor ( Math . random ( ) * 10000 ) ;
1111var client = new Paho . Client ( livedata , clientID ) ;
1212var clientConnected = false ;
13+ var clientActive = false ;
1314
1415var host_url = "" ;
1516var markers_url = "img/markers/" ;
@@ -341,9 +342,8 @@ function clean_refresh(text, force, history_step) {
341342 if ( text == wvar . mode && ! force ) return false ;
342343 stopAjax ( ) ;
343344
344- if ( clientConnected ) {
345- client . disconnect ( ) ;
346- clientConnected = false ;
345+ if ( clientActive ) {
346+ clientActive = false ;
347347 }
348348
349349 // reset mode if, invalid mode is specified
@@ -2927,35 +2927,40 @@ function liveData() {
29272927 function onConnect ( ) {
29282928 client . subscribe ( "#" ) ;
29292929 clientConnected = true ;
2930+ clientActive = true ;
29302931 } ;
29312932
29322933 function connectionError ( error ) {
29332934 $ ( "#stText" ) . text ( "error |" ) ;
29342935 clientConnected = false ;
2936+ clientActive = false ;
29352937 refresh ( ) ;
29362938 } ;
29372939
29382940 function onConnectionLost ( responseObject ) {
29392941 if ( responseObject . errorCode !== 0 ) {
29402942 clientConnected = false ;
2943+ clientActive = false ;
29412944 refresh ( ) ;
29422945 }
29432946 } ;
29442947
29452948 function onMessageArrived ( message ) {
2946- var frame = JSON . parse ( message . payloadString . toString ( ) ) ;
2947- if ( ( new Date ( ) . getTime ( ) - new Date ( frame . time_received ) . getTime ( ) ) < 30000 ) {
2948- var test = formatData ( frame , true ) ;
2949- if ( clientConnected ) {
2950- update ( test ) ;
2949+ if ( clientActive ) {
2950+ var frame = JSON . parse ( message . payloadString . toString ( ) ) ;
2951+ if ( ( new Date ( ) . getTime ( ) - new Date ( frame . time_received ) . getTime ( ) ) < 30000 ) {
2952+ var test = formatData ( frame , true ) ;
2953+ if ( clientActive ) {
2954+ update ( test ) ;
2955+ }
2956+ $ ( "#stTimer" ) . attr ( "data-timestamp" , new Date ( ) . getTime ( ) ) ;
2957+ $ ( "#stText" ) . text ( "websocket |" ) ;
2958+ } else if ( ( new Date ( ) . getTime ( ) - new Date ( frame . time_received ) . getTime ( ) ) > 150000 ) {
2959+ $ ( "#stText" ) . text ( "error |" ) ;
2960+ refresh ( ) ;
2961+ } else {
2962+ $ ( "#stText" ) . text ( "error |" ) ;
29512963 }
2952- $ ( "#stTimer" ) . attr ( "data-timestamp" , new Date ( ) . getTime ( ) ) ;
2953- $ ( "#stText" ) . text ( "websocket |" ) ;
2954- } else if ( ( new Date ( ) . getTime ( ) - new Date ( frame . time_received ) . getTime ( ) ) > 150000 ) {
2955- $ ( "#stText" ) . text ( "error |" ) ;
2956- refresh ( ) ;
2957- } else {
2958- $ ( "#stText" ) . text ( "error |" ) ;
29592964 }
29602965 } ;
29612966}
0 commit comments