mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Internal change
PiperOrigin-RevId: 372030567
This commit is contained in:
@@ -47,14 +47,8 @@ const std::size_t kEndpointIdLength = 4u;
|
||||
const std::size_t kMaxEndpointInfoLength = 131u;
|
||||
} // namespace
|
||||
|
||||
ServiceControllerRouter::ServiceControllerRouter(
|
||||
std::function<ServiceController*()> factory)
|
||||
: service_controller_factory_(std::move(factory)) {
|
||||
NEARBY_LOGS(INFO) << "ServiceControllerRouter going up.";
|
||||
}
|
||||
|
||||
ServiceControllerRouter::~ServiceControllerRouter() {
|
||||
NEARBY_LOGS(INFO) << "ServiceControllerRouter going down.";
|
||||
NEARBY_LOG(INFO, "ServiceControllerRouter going down.");
|
||||
|
||||
if (service_controller_) {
|
||||
service_controller_->Stop();
|
||||
@@ -224,11 +218,10 @@ void ServiceControllerRouter::AcceptConnection(ClientProxy* client,
|
||||
}
|
||||
|
||||
if (client->HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
<< "Client " << client->GetClientId()
|
||||
<< " invoked acceptConnectionRequest() after having already "
|
||||
"accepted/rejected the connection to endpoint(id="
|
||||
<< endpoint_id << ")";
|
||||
NEARBY_LOG(INFO,
|
||||
"[ServiceControllerRouter:Accept]: Client has local "
|
||||
"endpoint responded; id=%s",
|
||||
endpoint_id.c_str());
|
||||
callback.result_cb({Status::kOutOfOrderApiCall});
|
||||
return;
|
||||
}
|
||||
@@ -257,11 +250,10 @@ void ServiceControllerRouter::RejectConnection(ClientProxy* client,
|
||||
}
|
||||
|
||||
if (client->HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
<< "Client " << client->GetClientId()
|
||||
<< " invoked rejectConnectionRequest() after having already "
|
||||
"accepted/rejected the connection to endpoint(id="
|
||||
<< endpoint_id << ")";
|
||||
NEARBY_LOG(INFO,
|
||||
"[ServiceControllerRouter:Reject]: Client has local "
|
||||
"endpoint responded; id=%s",
|
||||
endpoint_id.c_str());
|
||||
callback.result_cb({Status::kOutOfOrderApiCall});
|
||||
return;
|
||||
}
|
||||
@@ -392,8 +384,9 @@ void ServiceControllerRouter::ClientDisconnecting(
|
||||
callback]() {
|
||||
if (ClientHasAcquiredServiceController(client)) {
|
||||
DoneWithStrategySessionForClient(client);
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
<< " has completed the client's connection.";
|
||||
NEARBY_LOG(INFO,
|
||||
"[ServiceControllerRouter:Disconnect]: Client has completed "
|
||||
"the client's connection");
|
||||
}
|
||||
callback.result_cb({Status::kSuccess});
|
||||
});
|
||||
@@ -426,14 +419,18 @@ Status ServiceControllerRouter::AcquireServiceControllerForClient(
|
||||
bool is_the_only_client_of_service_controller =
|
||||
clients_.size() == 1 && ClientHasAcquiredServiceController(client);
|
||||
if (!is_the_only_client_of_service_controller) {
|
||||
NEARBY_LOGS(INFO) << "Client has already active strategy.";
|
||||
NEARBY_LOG(INFO,
|
||||
"[ServiceControllerRouter:AcquireServiceControllerForClient]: "
|
||||
"Client has already active strategy.");
|
||||
return {Status::kAlreadyHaveActiveStrategy};
|
||||
}
|
||||
|
||||
// If the client still has connected endpoints, they must disconnect before
|
||||
// they can switch.
|
||||
if (!client->GetConnectedEndpoints().empty()) {
|
||||
NEARBY_LOGS(INFO) << "Client has connected endpoints.";
|
||||
NEARBY_LOG(INFO,
|
||||
"[ServiceControllerRouter:AcquireServiceControllerForClient]: "
|
||||
"Client has connected endpoints.");
|
||||
return {Status::kOutOfOrderApiCall};
|
||||
}
|
||||
|
||||
@@ -500,7 +497,7 @@ bool ServiceControllerRouter::ClientHasConnectionToAtLeastOneEndpoint(
|
||||
Status ServiceControllerRouter::UpdateCurrentServiceControllerAndStrategy(
|
||||
Strategy strategy) {
|
||||
if (!strategy.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "Strategy is not valid.";
|
||||
NEARBY_LOG(INFO, "Strategy is not valid.");
|
||||
return {Status::kError};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user