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:
committed by
Facebook GitHub Bot
parent
23682f914f
commit
cac09d14aa
89
iOS/FlipperKit/FlipperWebSocket.h
Normal file
89
iOS/FlipperKit/FlipperWebSocket.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <Flipper/FlipperSocket.h>
|
||||
#import <Flipper/FlipperSocketProvider.h>
|
||||
#import <Flipper/FlipperTransportTypes.h>
|
||||
#import <folly/dynamic.h>
|
||||
#import <folly/io/async/EventBase.h>
|
||||
#import <future>
|
||||
#import <memory>
|
||||
|
||||
@class FlipperPlatformWebSocket;
|
||||
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
class FlipperConnectionManager;
|
||||
class ConnectionContextStore;
|
||||
class FlipperWebSocket : public FlipperSocket {
|
||||
public:
|
||||
FlipperWebSocket(
|
||||
FlipperConnectionEndpoint endpoint,
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload,
|
||||
folly::EventBase* eventBase);
|
||||
FlipperWebSocket(
|
||||
FlipperConnectionEndpoint endpoint,
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload,
|
||||
folly::EventBase* eventBase,
|
||||
ConnectionContextStore* connectionContextStore);
|
||||
|
||||
virtual ~FlipperWebSocket() {}
|
||||
|
||||
virtual void setEventHandler(SocketEventHandler eventHandler) override;
|
||||
virtual void setMessageHandler(SocketMessageHandler messageHandler) override;
|
||||
|
||||
virtual bool connect(FlipperConnectionManager* manager) override;
|
||||
virtual void disconnect() override;
|
||||
|
||||
virtual void send(const folly::dynamic& message, SocketSendHandler completion)
|
||||
override;
|
||||
virtual void send(const std::string& message, SocketSendHandler completion)
|
||||
override;
|
||||
virtual void sendExpectResponse(
|
||||
const std::string& message,
|
||||
SocketSendExpectResponseHandler completion) override;
|
||||
|
||||
private:
|
||||
FlipperConnectionEndpoint endpoint_;
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload_;
|
||||
folly::EventBase* eventBase_;
|
||||
ConnectionContextStore* connectionContextStore_;
|
||||
|
||||
FlipperPlatformWebSocket* socket_;
|
||||
|
||||
SocketEventHandler eventHandler_;
|
||||
SocketMessageHandler messageHandler_;
|
||||
};
|
||||
|
||||
class FlipperWebSocketProvider : public FlipperSocketProvider {
|
||||
public:
|
||||
FlipperWebSocketProvider() {}
|
||||
virtual std::unique_ptr<FlipperSocket> create(
|
||||
FlipperConnectionEndpoint endpoint,
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload,
|
||||
folly::EventBase* eventBase) override {
|
||||
return std::make_unique<FlipperWebSocket>(
|
||||
std::move(endpoint), std::move(payload), eventBase);
|
||||
}
|
||||
virtual std::unique_ptr<FlipperSocket> create(
|
||||
FlipperConnectionEndpoint endpoint,
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload,
|
||||
folly::EventBase* eventBase,
|
||||
ConnectionContextStore* connectionContextStore) override {
|
||||
return std::make_unique<FlipperWebSocket>(
|
||||
std::move(endpoint),
|
||||
std::move(payload),
|
||||
eventBase,
|
||||
connectionContextStore);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace flipper
|
||||
} // namespace facebook
|
||||
Reference in New Issue
Block a user