Define boundaries between FlipperConnectionManager and RSocket on the client side
Summary: These changes abstract RSocket from FlipperConnectionManagerImpl. This is achieved by defining FlipperSocket. FlipperConnectionManagerImpl uses instances of FlipperSocket and RSocket is now contained within FlipperRSocket which implements FlipperSocket. On the changes to follow, FlipperConnectionManagerImpl will no longer reference FlipperRSocket directly thus fully abstracting the socket implementation in use. For reviewers: - All of the RSocket code now lives in FlipperRSocket. - Main changes are in FlipperConnectionManagerImpl. Lambdas are used to deal with events and message handling. - There's some very minimal serialisation additions for payloads. Reviewed By: jknoxville Differential Revision: D30341076 fbshipit-source-id: 54bb4878967378490710c05f729cdd7f4cf08bb8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4ae7d9c42b
commit
a9c6351cf0
76
xplat/Flipper/FlipperSocket.h
Normal file
76
xplat/Flipper/FlipperSocket.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <folly/dynamic.h>
|
||||
#include <rsocket/RSocket.h>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include "FlipperTransportTypes.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
class FlipperConnectionManager;
|
||||
class ConnectionContextStore;
|
||||
class FlipperSocket {
|
||||
public:
|
||||
virtual ~FlipperSocket() {}
|
||||
/**
|
||||
Sets the socket event handler. Used to observe underlying socket state
|
||||
changes.
|
||||
@param eventHandler Observer to be notified of state changes.
|
||||
*/
|
||||
virtual void setEventHandler(SocketEventHandler eventHandler) = 0;
|
||||
/**
|
||||
Sets the socket message handler. Used to handle received messages.
|
||||
@param messageHandler Received messages handler.
|
||||
*/
|
||||
virtual void setMessageHandler(SocketMessageHandler messageHandler) = 0;
|
||||
/**
|
||||
Connect the socket to the specified endpoint. This is a blocking call
|
||||
meaning that it will return once the socket is connected and ready to be
|
||||
used or error.
|
||||
@param manager An instance of FlipperConnectionManager.
|
||||
*/
|
||||
virtual bool connect(FlipperConnectionManager* manager) = 0;
|
||||
/**
|
||||
Disconnect from the endpoint.
|
||||
*/
|
||||
virtual void disconnect() = 0;
|
||||
/**
|
||||
Send a message to the receiving end.
|
||||
@param message A message to be sent.
|
||||
@param completion A completion handler to be invoked when the message has
|
||||
been sent.
|
||||
*/
|
||||
virtual void send(
|
||||
const folly::dynamic& message,
|
||||
SocketSendHandler completion) = 0;
|
||||
/**
|
||||
Send a message to the receiving end.
|
||||
@param message A message to be sent.
|
||||
@param completion A completion handler to be invoked when the message has
|
||||
been sent.
|
||||
*/
|
||||
virtual void send(
|
||||
const std::string& message,
|
||||
SocketSendHandler completion) = 0;
|
||||
/**
|
||||
Send a message and expect a response.
|
||||
@param message A message to be sent.
|
||||
@param completion A completion handler to be invoked when a response is
|
||||
received.
|
||||
*/
|
||||
virtual void sendExpectResponse(
|
||||
const std::string& message,
|
||||
SocketSendExpectResponseHandler completion) = 0;
|
||||
};
|
||||
|
||||
} // namespace flipper
|
||||
} // namespace facebook
|
||||
Reference in New Issue
Block a user