Socket provider

Summary:
Abstract the socket creation from FlipperConnectionManagerImpl. Instead, use FlipperSocketProvider.

There's a default provider which will always return RSocket sockets. This provider can be changed and thus can return other implementations.

Reviewed By: fabiomassimo

Differential Revision: D30396322

fbshipit-source-id: 0583865376809260b0240e5bd653d73f2fa514b1
This commit is contained in:
Lorenzo Blasa
2021-08-23 03:16:25 -07:00
committed by Facebook GitHub Bot
parent 823a90fa61
commit ef831f346d
4 changed files with 168 additions and 6 deletions

View File

@@ -8,7 +8,6 @@
#pragma once
#include <folly/dynamic.h>
#include <rsocket/RSocket.h>
#include <future>
#include <memory>
#include "FlipperTransportTypes.h"
@@ -26,12 +25,17 @@ class FlipperSocket {
changes.
@param eventHandler Observer to be notified of state changes.
*/
virtual void setEventHandler(SocketEventHandler eventHandler) = 0;
virtual void setEventHandler(SocketEventHandler eventHandler) {}
/**
Sets the socket message handler. Used to handle received messages.
@discussion Message handler is only ever used for WebSocket connections.
RSocket uses a different approach whereas a responder is used instead. We
could create an RSocket responder that uses a message handler as well. For
simplicity, and given that RSocket will be removed in future releases, it
was decided not to follow that path.
@param messageHandler Received messages handler.
*/
virtual void setMessageHandler(SocketMessageHandler messageHandler) = 0;
virtual void setMessageHandler(SocketMessageHandler messageHandler) {}
/**
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