Support iOS FlipperConnection send with array parameters
Summary: Achieving API parity with C++ and Android. Reviewed By: lblasa Differential Revision: D31921830 fbshipit-source-id: 873901107fc3c53166fa7bbaaff65ebdb0e53c2a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4a4cc21d89
commit
64df212cd3
@@ -25,12 +25,20 @@
|
|||||||
|
|
||||||
#pragma mark - SonarConnection
|
#pragma mark - SonarConnection
|
||||||
|
|
||||||
- (void)send:(NSString*)method withParams:(NSDictionary*)params {
|
- (void)sendInternal:(NSString*)method withParams:(id)params {
|
||||||
conn_->send(
|
conn_->send(
|
||||||
[method UTF8String],
|
[method UTF8String],
|
||||||
facebook::cxxutils::convertIdToFollyDynamic(params, true));
|
facebook::cxxutils::convertIdToFollyDynamic(params, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)send:(NSString*)method withParams:(NSDictionary*)params {
|
||||||
|
[self sendInternal:method withParams:params];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)send:(NSString*)method withArrayParams:(NSArray*)params {
|
||||||
|
[self sendInternal:method withParams:params];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)receive:(NSString*)method withBlock:(SonarReceiver)receiver {
|
- (void)receive:(NSString*)method withBlock:(SonarReceiver)receiver {
|
||||||
const auto lambda =
|
const auto lambda =
|
||||||
[receiver](
|
[receiver](
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ Invoke a method on the Sonar desktop plugin with with a matching identifier.
|
|||||||
*/
|
*/
|
||||||
- (void)send:(NSString*)method withParams:(NSDictionary*)params;
|
- (void)send:(NSString*)method withParams:(NSDictionary*)params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Invoke a method on the Sonar desktop plugin with with a matching identifier.
|
||||||
|
*/
|
||||||
|
- (void)send:(NSString*)method withArrayParams:(NSArray*)params;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Register a receiver to be notified of incoming calls of the given method from
|
Register a receiver to be notified of incoming calls of the given method from
|
||||||
the Sonar desktop plugin with a matching identifier.
|
the Sonar desktop plugin with a matching identifier.
|
||||||
|
|||||||
@@ -16,5 +16,7 @@
|
|||||||
NSDictionary<NSString*, SonarReceiver>* receivers;
|
NSDictionary<NSString*, SonarReceiver>* receivers;
|
||||||
@property(nonatomic, readonly)
|
@property(nonatomic, readonly)
|
||||||
NSDictionary<NSString*, NSArray<NSDictionary*>*>* sent;
|
NSDictionary<NSString*, NSArray<NSDictionary*>*>* sent;
|
||||||
|
@property(nonatomic, readonly)
|
||||||
|
NSDictionary<NSString*, NSArray<NSArray*>*>* sentWithArray;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -14,23 +14,34 @@
|
|||||||
_connected = YES;
|
_connected = YES;
|
||||||
_receivers = @{};
|
_receivers = @{};
|
||||||
_sent = @{};
|
_sent = @{};
|
||||||
|
_sentWithArray = @{};
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)send:(NSString*)method withParams:(NSDictionary*)params {
|
- (void)sendInternal:(NSString*)method
|
||||||
|
withParams:(id)params
|
||||||
|
loggedTo:(NSDictionary* __strong*)sentLog {
|
||||||
if (_connected) {
|
if (_connected) {
|
||||||
NSMutableDictionary* newSent = [NSMutableDictionary new];
|
NSMutableDictionary* newSentLog = [NSMutableDictionary new];
|
||||||
[newSent addEntriesFromDictionary:_sent];
|
[newSentLog addEntriesFromDictionary:*sentLog];
|
||||||
if (newSent[method]) {
|
if (newSentLog[method]) {
|
||||||
newSent[method] = [_sent[method] arrayByAddingObject:params];
|
newSentLog[method] = [(*sentLog)[method] arrayByAddingObject:params];
|
||||||
} else {
|
} else {
|
||||||
newSent[method] = @[ params ];
|
newSentLog[method] = @[ params ];
|
||||||
}
|
}
|
||||||
_sent = newSent;
|
*sentLog = newSentLog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)send:(NSString*)method withParams:(NSDictionary*)params {
|
||||||
|
[self sendInternal:method withParams:params loggedTo:&_sent];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)send:(NSString*)method withArrayParams:(NSArray*)params {
|
||||||
|
[self sendInternal:method withParams:params loggedTo:&_sentWithArray];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)receive:(NSString*)method withBlock:(SonarReceiver)receiver {
|
- (void)receive:(NSString*)method withBlock:(SonarReceiver)receiver {
|
||||||
if (_connected) {
|
if (_connected) {
|
||||||
NSMutableDictionary* newReceivers = [NSMutableDictionary new];
|
NSMutableDictionary* newReceivers = [NSMutableDictionary new];
|
||||||
|
|||||||
Reference in New Issue
Block a user