@@ -64,18 +64,6 @@ @implementation FOutstandingPut
64
64
65
65
@end
66
66
67
- @interface FOutstandingGet : NSObject
68
-
69
- @property (nonatomic , strong ) NSDictionary *request;
70
- @property (nonatomic , copy ) fbt_void_nsstring_id_nsstring onCompleteBlock;
71
- @property (nonatomic ) BOOL sent;
72
-
73
- @end
74
-
75
- @implementation FOutstandingGet
76
-
77
- @end
78
-
79
67
typedef enum {
80
68
ConnectionStateDisconnected,
81
69
ConnectionStateGettingToken,
@@ -104,11 +92,9 @@ - (void)sendOnDisconnectAction:(NSString *)action
104
92
@property (nonatomic , strong ) FConnection *realtime;
105
93
@property (nonatomic , strong ) NSMutableDictionary *listens;
106
94
@property (nonatomic , strong ) NSMutableDictionary *outstandingPuts;
107
- @property (nonatomic , strong ) NSMutableDictionary *outstandingGets;
108
95
@property (nonatomic , strong ) NSMutableArray *onDisconnectQueue;
109
96
@property (nonatomic , strong ) FRepoInfo *repoInfo;
110
97
@property (nonatomic , strong ) FAtomicNumber *putCounter;
111
- @property (nonatomic , strong ) FAtomicNumber *getCounter;
112
98
@property (nonatomic , strong ) FAtomicNumber *requestNumber;
113
99
@property (nonatomic , strong ) NSMutableDictionary *requestCBHash;
114
100
@property (nonatomic , strong ) FIRDatabaseConfig *config;
@@ -142,10 +128,8 @@ - (id)initWithRepoInfo:(FRepoInfo *)repoInfo
142
128
143
129
self.listens = [[NSMutableDictionary alloc ] init ];
144
130
self.outstandingPuts = [[NSMutableDictionary alloc ] init ];
145
- self.outstandingGets = [[NSMutableDictionary alloc ] init ];
146
131
self.onDisconnectQueue = [[NSMutableArray alloc ] init ];
147
132
self.putCounter = [[FAtomicNumber alloc ] init ];
148
- self.getCounter = [[FAtomicNumber alloc ] init ];
149
133
self.requestNumber = [[FAtomicNumber alloc ] init ];
150
134
self.requestCBHash = [[NSMutableDictionary alloc ] init ];
151
135
self.unackedListensCount = 0 ;
@@ -325,10 +309,6 @@ - (BOOL)canSendWrites {
325
309
return self->connectionState == ConnectionStateConnected;
326
310
}
327
311
328
- - (BOOL )canSendReads {
329
- return self->connectionState == ConnectionStateConnected;
330
- }
331
-
332
312
#pragma mark -
333
313
#pragma mark FConnection delegate methods
334
314
@@ -727,43 +707,6 @@ - (void)sendPut:(NSNumber *)index {
727
707
}];
728
708
}
729
709
730
- - (void )sendGet : (NSNumber *)index {
731
- NSAssert ([self canSendReads ],
732
- @" sendGet called when not able to send reads" );
733
- FOutstandingGet *get = self.outstandingGets [index];
734
- NSAssert (get != nil , @" sendGet found no outstanding get at index %@ " ,
735
- index);
736
- if ([get sent ]) {
737
- return ;
738
- }
739
- get.sent = YES ;
740
- [self sendAction: kFWPRequestActionGet
741
- body: get.request
742
- sensitive: NO
743
- callback: ^(NSDictionary *data) {
744
- FOutstandingGet *currentGet = self.outstandingGets [index];
745
- if (currentGet == get) {
746
- [self .outstandingGets removeObjectForKey: index];
747
- NSString *status =
748
- [data objectForKey: kFWPResponseForActionStatus ];
749
- id resultData = [data objectForKey: kFWPResponseForActionData ];
750
- if (resultData == (id )[NSNull null ]) {
751
- resultData = nil ;
752
- }
753
- if ([status isEqualToString: kFWPResponseForActionStatusOk ]) {
754
- get.onCompleteBlock (status, resultData, nil );
755
- return ;
756
- }
757
- get.onCompleteBlock (status, nil , resultData);
758
- } else {
759
- FFLog (@" I-RDB034045" ,
760
- @" Ignoring on complete for get %@ because it was "
761
- @" already removed" ,
762
- index);
763
- }
764
- }];
765
- }
766
-
767
710
- (void )sendUnlisten : (FPath *)path
768
711
queryParams : (FQueryParams *)queryParams
769
712
tagId : (NSNumber *)tagId {
@@ -816,46 +759,6 @@ - (void)putInternal:(id)data
816
759
}
817
760
}
818
761
819
- - (void )getDataAtPath : (NSString *)pathString
820
- withParams : (NSDictionary *)queryWireProtocolParams
821
- withCallback : (fbt_void_nsstring_id_nsstring)onComplete {
822
- NSMutableDictionary *request = [NSMutableDictionary
823
- dictionaryWithObjectsAndKeys: pathString, kFWPRequestPath ,
824
- queryWireProtocolParams,
825
- kFWPRequestQueries , nil ];
826
- FOutstandingGet *get = [[FOutstandingGet alloc ] init ];
827
- get.request = request;
828
- get.onCompleteBlock = onComplete;
829
- get.sent = NO ;
830
-
831
- NSNumber *index = [self .getCounter getAndIncrement ];
832
- self.outstandingGets [index] = get;
833
-
834
- if (![self connected ]) {
835
- dispatch_after (dispatch_time (DISPATCH_TIME_NOW,
836
- kPersistentConnectionGetConnectTimeout ),
837
- self.dispatchQueue , ^{
838
- FOutstandingGet *get = self.outstandingGets [index];
839
- if ([get sent ]) {
840
- return ;
841
- }
842
- FFLog (@" I-RDB034045" ,
843
- @" get %@ timed out waiting for a connection" ,
844
- index);
845
- get.sent = YES ;
846
- [self .outstandingGets removeObjectForKey: index];
847
- get.onCompleteBlock (kFWPResponseForActionStatusFailed ,
848
- nil , kPersistentConnectionOffline );
849
- });
850
- return ;
851
- }
852
-
853
- if ([self canSendReads ]) {
854
- FFLog (@" I-RDB034024" , @" Sending get: %@ " , index);
855
- [self sendGet: index];
856
- }
857
- }
858
-
859
762
- (void )sendListen : (FOutstandingQuery *)listenSpec {
860
763
FQuerySpec *query = listenSpec.query ;
861
764
FFLog (@" I-RDB034026" , @" Listen for %@ " , query);
@@ -1095,30 +998,17 @@ - (void)restoreState {
1095
998
[self sendListen: outstandingListen];
1096
999
}];
1097
1000
1098
- NSArray *putKeys = [[self .outstandingPuts allKeys ]
1001
+ NSArray *keys = [[self .outstandingPuts allKeys ]
1099
1002
sortedArrayUsingSelector: @selector (compare: )];
1100
- for (int i = 0 ; i < [putKeys count ]; i++) {
1101
- if ([self .outstandingPuts objectForKey: [putKeys objectAtIndex: i]] !=
1102
- nil ) {
1003
+ for (int i = 0 ; i < [keys count ]; i++) {
1004
+ if ([self .outstandingPuts objectForKey: [keys objectAtIndex: i]] != nil ) {
1103
1005
FFLog (@" I-RDB034037" , @" Restoring put: %d " , i);
1104
- [self sendPut: [putKeys objectAtIndex: i]];
1006
+ [self sendPut: [keys objectAtIndex: i]];
1105
1007
} else {
1106
1008
FFLog (@" I-RDB034038" , @" Restoring put: skipped nil: %d " , i);
1107
1009
}
1108
1010
}
1109
1011
1110
- NSArray *getKeys = [[self .outstandingGets allKeys ]
1111
- sortedArrayUsingSelector: @selector (compare: )];
1112
- for (int i = 0 ; i < [getKeys count ]; i++) {
1113
- if ([self .outstandingGets objectForKey: [getKeys objectAtIndex: i]] !=
1114
- nil ) {
1115
- FFLog (@" I-RDB034037" , @" Restoring get: %d " , i);
1116
- [self sendGet: [getKeys objectAtIndex: i]];
1117
- } else {
1118
- FFLog (@" I-RDB034038" , @" Restoring get: skipped nil: %d " , i);
1119
- }
1120
- }
1121
-
1122
1012
for (FTupleOnDisconnect *tuple in self.onDisconnectQueue ) {
1123
1013
[self sendOnDisconnectAction: tuple.action
1124
1014
forPath: tuple.pathString
0 commit comments