#ifndef CORE_INTERNAL_SERVICE_CONTROLLER_ROUTER_H_ #define CORE_INTERNAL_SERVICE_CONTROLLER_ROUTER_H_ #include #include #include "core/internal/client_proxy.h" #include "core/internal/service_controller.h" #include "core/params.h" #include "platform/port/string.h" #include "platform/ptr.h" #include "platform/runnable.h" namespace location { namespace nearby { namespace connections { namespace service_controller_router { template class StartAdvertisingRunnable; template class StopAdvertisingRunnable; template class StartDiscoveryRunnable; template class StopDiscoveryRunnable; template class SendConnectionRequestRunnable; template class AcceptConnectionRequestRunnable; template class RejectConnectionRequestRunnable; template class InitiateBandwidthUpgradeRunnable; template class SendPayloadRunnable; template class CancelPayloadRunnable; template class DisconnectFromEndpointRunnable; template class StopAllEndpointsRunnable; template class ClientDisconnectingRunnable; } // namespace service_controller_router template class ServiceControllerRouter { public: ServiceControllerRouter(); ~ServiceControllerRouter(); void startAdvertising( Ptr > client_proxy, ConstPtr start_advertising_params); void stopAdvertising(Ptr > client_proxy, ConstPtr stop_advertising_params); void startDiscovery(Ptr > client_proxy, ConstPtr start_discovery_params); void stopDiscovery(Ptr > client_proxy, ConstPtr stop_discovery_params); void requestConnection( Ptr > client_proxy, ConstPtr request_connection_params); void acceptConnection( Ptr > client_proxy, ConstPtr accept_connection_params); void rejectConnection( Ptr > client_proxy, ConstPtr reject_connection_params); void initiateBandwidthUpgrade(Ptr > client_proxy, ConstPtr initiate_bandwidth_upgrade_params); void sendPayload(Ptr > client_proxy, ConstPtr send_payload_params); void cancelPayload(Ptr > client_proxy, ConstPtr cancel_payload_params); void disconnectFromEndpoint( Ptr > client_proxy, ConstPtr disconnect_from_endpoint_params); void stopAllEndpoints( Ptr > client_proxy, ConstPtr stop_all_endpoint_params); void clientDisconnecting(Ptr > client_proxy); private: template friend class service_controller_router::StartAdvertisingRunnable; template friend class service_controller_router::StopAdvertisingRunnable; template friend class service_controller_router::StartDiscoveryRunnable; template friend class service_controller_router::StopDiscoveryRunnable; template friend class service_controller_router::SendConnectionRequestRunnable; template friend class service_controller_router::AcceptConnectionRequestRunnable; template friend class service_controller_router::RejectConnectionRequestRunnable; template friend class service_controller_router::InitiateBandwidthUpgradeRunnable; template friend class service_controller_router::SendPayloadRunnable; template friend class service_controller_router::CancelPayloadRunnable; template friend class service_controller_router::DisconnectFromEndpointRunnable; template friend class service_controller_router::StopAllEndpointsRunnable; template friend class service_controller_router::ClientDisconnectingRunnable; static bool clientHasConnectionToAtLeastOneEndpoint( Ptr > client_proxy, const std::vector& remote_endpoint_ids); void routeToServiceController(Ptr runnable); Status::Value acquireServiceControllerForClient( Ptr > client_proxy, const Strategy& strategy); bool clientHasAquiredServiceController( Ptr > client_proxy); void releaseServiceControllerForClient( Ptr > client_proxy); void doneWithStrategySessionForClient( Ptr > client_proxy); Status::Value updateCurrentServiceControllerAndStrategy( const Strategy& strategy); std::set > > current_service_controller_clients_; Ptr > current_service_controller_; Ptr current_strategy_; ScopedPtr > serializer_; std::shared_ptr> self_{this, [](void*){}}; }; } // namespace connections } // namespace nearby } // namespace location #include "core/internal/service_controller_router.cc" #endif // CORE_INTERNAL_SERVICE_CONTROLLER_ROUTER_H_