mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: Ia0cddfc8cf46c66d5739bdb45ab7825422912082
68 lines
2.5 KiB
C++
68 lines
2.5 KiB
C++
#ifndef CORE_V2_INTERNAL_PCP_MANAGER_H_
|
|
#define CORE_V2_INTERNAL_PCP_MANAGER_H_
|
|
|
|
#include <string>
|
|
|
|
#include "core_v2/internal/base_pcp_handler.h"
|
|
#include "core_v2/internal/client_proxy.h"
|
|
#include "core_v2/internal/endpoint_channel_manager.h"
|
|
#include "core_v2/internal/endpoint_manager.h"
|
|
#include "core_v2/internal/mediums/mediums.h"
|
|
#include "core_v2/listeners.h"
|
|
#include "core_v2/options.h"
|
|
#include "core_v2/status.h"
|
|
#include "core_v2/strategy.h"
|
|
#include "platform_v2/public/atomic_boolean.h"
|
|
#include "absl/container/flat_hash_map.h"
|
|
|
|
namespace location {
|
|
namespace nearby {
|
|
namespace connections {
|
|
|
|
// Manages all known PcpHandler implementations, delegating operations to the
|
|
// appropriate one as per the parameters passed in.
|
|
//
|
|
// This will only ever be used by the OfflineServiceController, which has all
|
|
// of its entrypoints invoked serially, so there's no synchronization needed.
|
|
// Public method semantics matches definition in the
|
|
// https://source.corp.google.com/piper///depot/google3/core_v2/internal/service_controller.h
|
|
class PcpManager {
|
|
public:
|
|
PcpManager(Mediums& mediums, EndpointChannelManager& channel_manager,
|
|
EndpointManager& endpoint_manager);
|
|
~PcpManager();
|
|
|
|
Status StartAdvertising(ClientProxy* client_proxy, const string& service_id,
|
|
const ConnectionOptions& options,
|
|
const ConnectionRequestInfo& info);
|
|
void StopAdvertising(ClientProxy* client_proxy);
|
|
|
|
Status StartDiscovery(ClientProxy* client_proxy, const string& service_id,
|
|
const ConnectionOptions& options,
|
|
DiscoveryListener listener);
|
|
void StopDiscovery(ClientProxy* client_proxy);
|
|
|
|
Status RequestConnection(ClientProxy* client_proxy, const string& endpoint_id,
|
|
const ConnectionRequestInfo& info);
|
|
Status AcceptConnection(ClientProxy* client_proxy, const string& endpoint_id,
|
|
const PayloadListener& payload_listener);
|
|
Status RejectConnection(ClientProxy* client_proxy, const string& endpoint_id);
|
|
|
|
proto::connections::Medium GetBandwidthUpgradeMedium();
|
|
void DisconnectFromEndpointManager();
|
|
|
|
private:
|
|
bool SetCurrentPcpHandler(Strategy strategy);
|
|
PcpHandler* GetPcpHandler(Pcp pcp) const;
|
|
|
|
AtomicBoolean shutdown_{false};
|
|
absl::flat_hash_map<Pcp, std::unique_ptr<BasePcpHandler>> handlers_;
|
|
PcpHandler* current_ = nullptr;
|
|
};
|
|
|
|
} // namespace connections
|
|
} // namespace nearby
|
|
} // namespace location
|
|
|
|
#endif // CORE_V2_INTERNAL_PCP_MANAGER_H_
|