private TimerTask getTask ( ) { TimerTask checkForRestartTask = new TimerTask ( ) { @ Override public void run ( ) { if ( lastPongAt == 0 ) return ; Date currentDate = new Date ( ) ; long timeInterval = ( currentDate . getTime ( ) - lastPongAt ) ; if ( timeInterval >= 2 * pingInterval ) { doReconnect ( ) ; } } } ; return checkForRestartTask ; }
Returns task which performs check every second for reconnection .