what-the-bank/sources/com/google/firebase/firestore/remote/WatchStream.java

78 lines
3.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.firestore.remote;
import com.google.firebase.firestore.local.TargetData;
import com.google.firebase.firestore.model.SnapshotVersion;
import com.google.firebase.firestore.remote.Stream;
import com.google.firebase.firestore.util.Assert;
import com.google.firebase.firestore.util.AsyncQueue;
import java.util.Map;
import o.C0993Tei;
import o.GMq;
import o.QwV;
import o.ZMV;
/* loaded from: classes2.dex */
public class WatchStream extends AbstractStream<C0993Tei, ZMV, Callback> {
public static final QwV EMPTY_RESUME_TOKEN = QwV.a;
private final RemoteSerializer serializer;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public interface Callback extends Stream.StreamCallback {
void onWatchChange(SnapshotVersion snapshotVersion, WatchChange watchChange);
}
@Override // com.google.firebase.firestore.remote.AbstractStream
public /* bridge */ /* synthetic */ void inhibitBackoff() {
super.inhibitBackoff();
}
@Override // com.google.firebase.firestore.remote.AbstractStream
public /* bridge */ /* synthetic */ boolean isOpen() {
return super.isOpen();
}
@Override // com.google.firebase.firestore.remote.AbstractStream
public /* bridge */ /* synthetic */ boolean isStarted() {
return super.isStarted();
}
@Override // com.google.firebase.firestore.remote.AbstractStream
public /* bridge */ /* synthetic */ void start() {
super.start();
}
@Override // com.google.firebase.firestore.remote.AbstractStream
public /* bridge */ /* synthetic */ void stop() {
super.stop();
}
/* JADX INFO: Access modifiers changed from: package-private */
public WatchStream(FirestoreChannel firestoreChannel, AsyncQueue asyncQueue, RemoteSerializer remoteSerializer, Callback callback) {
super(firestoreChannel, GMq.a(), asyncQueue, AsyncQueue.TimerId.LISTEN_STREAM_CONNECTION_BACKOFF, AsyncQueue.TimerId.LISTEN_STREAM_IDLE, AsyncQueue.TimerId.HEALTH_CHECK_TIMEOUT, callback);
this.serializer = remoteSerializer;
}
public void watchQuery(TargetData targetData) {
Assert.hardAssert(isOpen(), "Watching queries requires an open stream", new Object[0]);
C0993Tei.LWm e = C0993Tei.e().e(this.serializer.databaseName()).e(this.serializer.encodeTarget(targetData));
Map<String, String> encodeListenRequestLabels = this.serializer.encodeListenRequestLabels(targetData);
if (encodeListenRequestLabels != null) {
e.a(encodeListenRequestLabels);
}
writeRequest(e.build());
}
public void unwatchTarget(int i) {
Assert.hardAssert(isOpen(), "Unwatching targets requires an open stream", new Object[0]);
writeRequest(C0993Tei.e().e(this.serializer.databaseName()).d(i).build());
}
@Override // com.google.firebase.firestore.remote.AbstractStream
public void onNext(ZMV zmv) {
this.backoff.reset();
WatchChange decodeWatchChange = this.serializer.decodeWatchChange(zmv);
((Callback) this.listener).onWatchChange(this.serializer.decodeVersionFromListenResponse(zmv), decodeWatchChange);
}
}