private void initStream ( ) { firestoreExecutor . schedule ( new Runnable ( ) { @ Override public void run ( ) { if ( ! isActive . get ( ) ) { return ; } synchronized ( Watch . this ) { if ( ! isActive . get ( ) ) { return ; } Preconditions . checkState ( stream == null ) ; current = false ; nextAttempt = backoff . createNextAttempt ( nextAttempt ) ; stream = firestore . streamRequest ( Watch . this , firestore . getClient ( ) . listenCallable ( ) ) ; ListenRequest . Builder request = ListenRequest . newBuilder ( ) ; request . setDatabase ( firestore . getDatabaseName ( ) ) ; request . setAddTarget ( target ) ; if ( resumeToken != null ) { request . getAddTargetBuilder ( ) . setResumeToken ( resumeToken ) ; } stream . onNext ( request . build ( ) ) ; } } } , nextAttempt . getRandomizedRetryDelay ( ) . toMillis ( ) , TimeUnit . MILLISECONDS ) ; }
Initializes a new stream to the backend with backoff .