mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Roll forward up to cl/353292511.
This commit is contained in:
@@ -146,6 +146,10 @@ void ServiceControllerRouter::RequestConnection(
|
||||
ClientProxy* client, absl::string_view endpoint_id,
|
||||
const ConnectionRequestInfo& info, const ConnectionOptions& options,
|
||||
const ResultCallback& callback) {
|
||||
// Cancellations can be fired from clients anytime, need to add the
|
||||
// CancellationListener as soon as possible.
|
||||
client->AddCancellationFlag(std::string(endpoint_id));
|
||||
|
||||
RouteToServiceController([this, client,
|
||||
endpoint_id = std::string(endpoint_id), info,
|
||||
options, callback]() {
|
||||
@@ -160,8 +164,12 @@ void ServiceControllerRouter::RequestConnection(
|
||||
return;
|
||||
}
|
||||
|
||||
callback.result_cb(service_controller_->RequestConnection(
|
||||
client, endpoint_id, info, options));
|
||||
Status status = service_controller_->RequestConnection(client, endpoint_id,
|
||||
info, options);
|
||||
if (!status.Ok()) {
|
||||
client->CancelEndpoint(endpoint_id);
|
||||
}
|
||||
callback.result_cb(status);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,6 +207,8 @@ void ServiceControllerRouter::AcceptConnection(ClientProxy* client,
|
||||
void ServiceControllerRouter::RejectConnection(ClientProxy* client,
|
||||
absl::string_view endpoint_id,
|
||||
const ResultCallback& callback) {
|
||||
client->CancelEndpoint(std::string(endpoint_id));
|
||||
|
||||
RouteToServiceController(
|
||||
[this, client, endpoint_id = std::string(endpoint_id), callback]() {
|
||||
if (!ClientHasAcquiredServiceController(client)) {
|
||||
@@ -296,6 +306,10 @@ void ServiceControllerRouter::CancelPayload(ClientProxy* client,
|
||||
void ServiceControllerRouter::DisconnectFromEndpoint(
|
||||
ClientProxy* client, absl::string_view endpoint_id,
|
||||
const ResultCallback& callback) {
|
||||
// Client can emit the cancellation at anytime, we need to execute the request
|
||||
// without further posting it.
|
||||
client->CancelEndpoint(std::string(endpoint_id));
|
||||
|
||||
RouteToServiceController(
|
||||
[this, client, endpoint_id = std::string(endpoint_id), callback]() {
|
||||
if (ClientHasAcquiredServiceController(client)) {
|
||||
@@ -312,6 +326,10 @@ void ServiceControllerRouter::DisconnectFromEndpoint(
|
||||
|
||||
void ServiceControllerRouter::StopAllEndpoints(ClientProxy* client,
|
||||
const ResultCallback& callback) {
|
||||
// Client can emit the cancellation at anytime, we need to execute the request
|
||||
// without further posting it.
|
||||
client->CancelAllEndpoints();
|
||||
|
||||
RouteToServiceController([this, client, callback]() {
|
||||
if (ClientHasAcquiredServiceController(client)) {
|
||||
DoneWithStrategySessionForClient(client);
|
||||
@@ -322,6 +340,10 @@ void ServiceControllerRouter::StopAllEndpoints(ClientProxy* client,
|
||||
|
||||
void ServiceControllerRouter::ClientDisconnecting(
|
||||
ClientProxy* client, const ResultCallback& callback) {
|
||||
// Client can emit the cancellation at anytime, we need to execute the request
|
||||
// without further posting it.
|
||||
client->CancelAllEndpoints();
|
||||
|
||||
RouteToServiceController([this, client, callback]() {
|
||||
if (ClientHasAcquiredServiceController(client)) {
|
||||
DoneWithStrategySessionForClient(client);
|
||||
|
||||
Reference in New Issue
Block a user