mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
nearby: snapshot as of cl/296436629
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: I2cf5bf225b76f4c1541954651f3a7544a14e0cec
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
#ifndef CORE_INTERNAL_PCP_MANAGER_H_
|
||||
#define CORE_INTERNAL_PCP_MANAGER_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "core/internal/bandwidth_upgrade_manager.h"
|
||||
#include "core/internal/client_proxy.h"
|
||||
#include "core/internal/endpoint_channel_manager.h"
|
||||
#include "core/internal/endpoint_manager.h"
|
||||
#include "core/internal/medium_manager.h"
|
||||
#include "core/internal/pcp_handler.h"
|
||||
#include "core/listeners.h"
|
||||
#include "core/options.h"
|
||||
#include "core/status.h"
|
||||
#include "core/strategy.h"
|
||||
#include "platform/port/string.h"
|
||||
#include "platform/ptr.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
|
||||
// Manages all known PCPHandler implementations, delegating operations to the
|
||||
// appropriate one as per the parameters passed in.
|
||||
//
|
||||
// <p>This will only ever be used by the OfflineServiceController, which has all
|
||||
// of its entrypoints invoked serially, so there's no synchronization needed.
|
||||
template <typename Platform>
|
||||
class PCPManager {
|
||||
public:
|
||||
PCPManager(Ptr<MediumManager<Platform> > medium_manager,
|
||||
Ptr<EndpointChannelManager<Platform> > endpoint_channel_manager,
|
||||
Ptr<EndpointManager<Platform> > endpoint_manager,
|
||||
Ptr<BandwidthUpgradeManager<Platform> > bandwidth_upgrade_manager);
|
||||
~PCPManager();
|
||||
|
||||
Status::Value startAdvertising(
|
||||
Ptr<ClientProxy<Platform> > client_proxy, const string& endpoint_name,
|
||||
const string& service_id, const AdvertisingOptions& advertising_options,
|
||||
Ptr<ConnectionLifecycleListener> connection_lifecycle_listener);
|
||||
void stopAdvertising(Ptr<ClientProxy<Platform> > client_proxy);
|
||||
|
||||
Status::Value startDiscovery(Ptr<ClientProxy<Platform> > client_proxy,
|
||||
const string& service_id,
|
||||
const DiscoveryOptions& discovery_options,
|
||||
Ptr<DiscoveryListener> discovery_listener);
|
||||
void stopDiscovery(Ptr<ClientProxy<Platform> > client_proxy);
|
||||
|
||||
Status::Value requestConnection(
|
||||
Ptr<ClientProxy<Platform> > client_proxy, const string& endpoint_name,
|
||||
const string& endpoint_id,
|
||||
Ptr<ConnectionLifecycleListener> connection_lifecycle_listener);
|
||||
Status::Value acceptConnection(Ptr<ClientProxy<Platform> > client_proxy,
|
||||
const string& endpoint_id,
|
||||
Ptr<PayloadListener> payload_listener);
|
||||
Status::Value rejectConnection(Ptr<ClientProxy<Platform> > client_proxy,
|
||||
const string& endpoint_id);
|
||||
|
||||
proto::connections::Medium getBandwidthUpgradeMedium();
|
||||
|
||||
private:
|
||||
bool setCurrentPCPHandler(const Strategy& strategy);
|
||||
PCP::Value deducePCP(const Strategy& strategy);
|
||||
Ptr<PCPHandler<Platform> > getPCPHandler(PCP::Value pcp);
|
||||
|
||||
typedef std::map<PCP::Value, Ptr<PCPHandler<Platform> > > PCPHandlersMap;
|
||||
PCPHandlersMap pcp_handlers_;
|
||||
Ptr<PCPHandler<Platform> > current_pcp_handler_;
|
||||
};
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#include "core/internal/pcp_manager.cc"
|
||||
|
||||
#endif // CORE_INTERNAL_PCP_MANAGER_H_
|
||||
Reference in New Issue
Block a user