private void scheduleReconnection ( ) { if ( runnable != null ) { handler . removeCallbacks ( runnable ) ; } runnable = ( ) -> { if ( shouldReconnect ( ) && ( socket == null || ! socket . isOpen ( ) ) && retryStrategy . retry ( ) && ! isNetworkUnavailable ) { log . d ( "Reconnecting socket" ) ; connect ( ) ; } } ; long delay = retryStrategy . getDelay ( ) ; handler . postDelayed ( runnable , delay ) ; log . d ( "Socket reconnection in " + delay / 1000 + " seconds." ) ; }
Schedule socket connection retry .