New 'isConnected' API

Summary: Expose the newly created `isConnected` API to iOS FlipperClient API.

Reviewed By: antonk52

Differential Revision: D46841190

fbshipit-source-id: c36eb08427d60c73fad8f92100df5d012149b4a8
This commit is contained in:
Lorenzo Blasa
2023-06-20 00:46:55 -07:00
committed by Facebook GitHub Bot
parent 7cec520729
commit 63f8c47cfa
2 changed files with 20 additions and 9 deletions

View File

@@ -13,7 +13,7 @@
#import "FlipperStateUpdateListener.h" #import "FlipperStateUpdateListener.h"
/** /**
Represents a connection between the Sonar desktop och client side. Manages the Represents a connection between the Flipper desktop client side. Manages the
lifecycle of attached plugin instances. lifecycle of attached plugin instances.
*/ */
@interface FlipperClient : NSObject @interface FlipperClient : NSObject
@@ -41,41 +41,48 @@ this client.
- (NSObject<FlipperPlugin>*)pluginWithIdentifier:(NSString*)identifier; - (NSObject<FlipperPlugin>*)pluginWithIdentifier:(NSString*)identifier;
/** /**
Establish a connection to the Sonar desktop. Establish a connection to the Flipper desktop.
*/ */
- (void)start; - (void)start;
/** /**
Stop the connection to the Sonar desktop. Stop the connection to the Flipper desktop.
*/ */
- (void)stop; - (void)stop;
/** /**
Get the log of state changes from the sonar client Get the log of state changes from the Flipper client.
*/ */
- (NSString*)getState; - (NSString*)getState;
/** /**
Get the current summarized state of the sonar client Get the current summarized state of the Flipper client.
*/ */
- (NSArray<NSDictionary*>*)getStateElements; - (NSArray<NSDictionary*>*)getStateElements;
/** /**
Subscribe a ViewController to state update change notifications Return true if the app is connected to Flipper desktop. Otherwise, returns
false.
*/
- (BOOL)isConnected;
/**
Subscribe a ViewController to state update change notifications.
*/ */
- (void)subscribeForUpdates:(id<FlipperStateUpdateListener>)controller; - (void)subscribeForUpdates:(id<FlipperStateUpdateListener>)controller;
/** /**
Sets the certificate provider responsible for obtaining certificates Sets the certificate provider responsible for obtaining certificates.
*/ */
- (void)setCertificateProvider:(id<FlipperKitCertificateProvider>)provider; - (void)setCertificateProvider:(id<FlipperKitCertificateProvider>)provider;
/** /**
Get the certificate provider of Flipper Client Get the certificate provider of Flipper Client.
*/ */
- (id<FlipperKitCertificateProvider>)getCertificateProvider; - (id<FlipperKitCertificateProvider>)getCertificateProvider;
// initializers are disabled. You must use `+[FlipperClient sharedClient]` // Initializers are disabled. You must use `+[FlipperClient sharedClient]`
// instance. // instance.
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE;

View File

@@ -182,6 +182,10 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
#endif #endif
} }
- (BOOL)isConnected {
return _cppClient->isConnected();
}
- (NSString*)getState { - (NSString*)getState {
return @(_cppClient->getState().c_str()); return @(_cppClient->getState().c_str());
} }