Files
flipper/xplat/Flipper/FlipperSocketProvider.h
Vitalii Ganzha 1a6e0ef42e Update FlipperPlugin C++ code so it can be compiled for Windows
Summary:
I am working in Horizon Worlds and I would like to integrate Flipper with HzW app.
Currently FlipperPlugin C++ code won't compile on Windows since it uses Linux-only headers like `netdb.h` and `sys/fcntl.h`, I posted here and looks like it is not currently supported: https://fb.workplace.com/groups/flippersupport/posts/1704837183330266

The problem seem to be in only in `FlipperConnectionEndpointVerifier.cpp`, and I'm updating it to make it compatible with Windows.

Also apparently there's some issue with `#include` of few files and namespaces, leading to "struct redefinition" errors where `#pragma once` does not help https://fb.workplace.com/groups/474291069286180/posts/25313067014981908/

Solving it with manual #define

Reviewed By: lblasa

Differential Revision: D50337573

fbshipit-source-id: affdf1aee2b9dfe615227827fedf324a5f17d8b0
2023-10-17 09:49:11 -07:00

82 lines
2.5 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and 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
#ifndef _FLIPPERSOCKETPROVIDER_H_
#define _FLIPPERSOCKETPROVIDER_H_
#include <memory>
#include "FlipperScheduler.h"
namespace facebook {
namespace flipper {
class FlipperSocket;
class FlipperConnectionManager;
class ConnectionContextStore;
struct FlipperConnectionEndpoint;
struct FlipperSocketBasePayload;
/**
A socket provider is responsible of the creation of FlipperSocket instances.
It also defines static factory methods that can be used to construct such
instances.
*/
class FlipperSocketProvider {
public:
virtual ~FlipperSocketProvider() {}
/**
Create an instance of FlipperSocket.
@param endpoint Endpoint to connect to.
@param payload Any configuration payload to establish a connection with
the specified endpoint.
@param scheduler An scheduler used to schedule and execute connection
operations.
*/
virtual std::unique_ptr<FlipperSocket> create(
FlipperConnectionEndpoint endpoint,
std::unique_ptr<FlipperSocketBasePayload> payload,
Scheduler* scheduler) = 0;
/**
Create an instance of FlipperSocket.
@param endpoint Endpoint to connect to.
@param payload Any configuration payload to establish a connection with
the specified endpoint.
@param scheduler An scheduler used to schedule and execute connection
operations.
@param connectionContextStore A connection context store used for obtaining
the certificate used for secure connections.
*/
virtual std::unique_ptr<FlipperSocket> create(
FlipperConnectionEndpoint endpoint,
std::unique_ptr<FlipperSocketBasePayload> payload,
Scheduler* scheduler,
ConnectionContextStore* connectionContextStore) = 0;
static std::unique_ptr<FlipperSocket> socketCreate(
FlipperConnectionEndpoint endpoint,
std::unique_ptr<FlipperSocketBasePayload> payload,
Scheduler* scheduler);
static std::unique_ptr<FlipperSocket> socketCreate(
FlipperConnectionEndpoint endpoint,
std::unique_ptr<FlipperSocketBasePayload> payload,
Scheduler* scheduler,
ConnectionContextStore* connectionContextStore);
static void setDefaultProvider(
std::unique_ptr<FlipperSocketProvider> provider);
static bool hasProvider();
private:
static std::unique_ptr<FlipperSocketProvider>& defaultProvider();
};
} // namespace flipper
} // namespace facebook
#endif