FlipperWebSocket

Summary:
Contains the implementation of FlipperWebSocket with any necessary changes to use it but without switching it on.

About SocketRocket and Cocoapods

A decision had to be made about whether to define different sub-specs, one for RSocket and another for SocketRocket.

I've opted to keep the podspec as is because:
- Keeps pod consumption as is.
- Makes easier to switch implementations using GK.
- There's no intention to keep RSocket going into the future. So, there's no point in creating a sub-spec only to remove it in the future.
- SocketRocket is a relatively small library so is not contributing to a significant increase in binary size.

If, as reviewer, you consider a subspec makes more sense, then feel free to reach out to discuss.

Reviewed By: fabiomassimo

Differential Revision: D30371791

fbshipit-source-id: 225c5b1de76aff1a6e36640a41765b963aaa2796
This commit is contained in:
Lorenzo Blasa
2021-08-26 09:01:17 -07:00
committed by Facebook GitHub Bot
parent 23682f914f
commit cac09d14aa
10 changed files with 650 additions and 33 deletions

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Flipper/FlipperTransportTypes.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Defines a WebSocket transport to be used by Flipper. It just acts as a
/// wrapper on top of a WebSocket connection mainly used to abstract the actual
/// used implementation.
@interface FlipperPlatformWebSocket : NSObject
/// An event handler used to dispatch socket events to the caller.
@property(nonatomic) facebook::flipper::SocketEventHandler eventHandler;
/// A message handler used to dispatch messages received from the server.
@property(nonatomic) facebook::flipper::SocketMessageHandler messageHandler;
/// A certificate provider used to obtain the client certificate used for
/// authentication.
@property(nonatomic)
facebook::flipper::SocketCertificateProvider certificateProvider;
/// Initializes an instance of FliperWebSocketTransport with an endpoint URL.
/// @param url Endpoint URL used to establish the connection.
- (instancetype)initWithURL:(NSURL* _Nonnull)url;
/// Connect to the endpoint.
- (void)connect;
/// Disconnects from the endpoint.
- (void)disconnect;
/// Send a message to the endpoint.
/// @param message The message as text to be sent to the endpoint.
/// @param error A pointer to variable for an `NSError` object.
/// If an error occurs, the pointer is set to an `NSError` object containing
/// information about the error. You may specify `nil` to ignore the error
/// information.
- (void)send:(NSString*)message error:(NSError**)error;
@end
NS_ASSUME_NONNULL_END