From 40ac9b3b25a30919d35deee09e658224dd474e6e Mon Sep 17 00:00:00 2001 From: hai007 Date: Fri, 14 Jan 2022 11:52:02 -0800 Subject: [PATCH] Implement Disconnect from Endpoint feature PiperOrigin-RevId: 421878981 --- windows/dart/core_adapter_dart.cc | 12 ++++++++++++ windows/dart/core_adapter_dart.h | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/windows/dart/core_adapter_dart.cc b/windows/dart/core_adapter_dart.cc index 5f17b262..beaf3564 100644 --- a/windows/dart/core_adapter_dart.cc +++ b/windows/dart/core_adapter_dart.cc @@ -457,6 +457,18 @@ void AcceptConnectionDart(Core *pCore, const char *endpoint_id, AcceptConnection(pCore, endpoint_id, listener, callback); } +void DisconnectFromEndpointDart(Core *pCore, char *endpoint_id, + Dart_Port result_cb) { + if (!pCore) { + PostResult(result_cb, Status::Value::kError); + return; + } + + ResultCallback callback; + SetResultCallback(callback, result_cb); + DisconnectFromEndpoint(pCore, endpoint_id, callback); +} + std::string GetPayloadPath(location::nearby::PayloadId payload_id) { PWSTR basePath; diff --git a/windows/dart/core_adapter_dart.h b/windows/dart/core_adapter_dart.h index c514c50c..bdcc86c0 100644 --- a/windows/dart/core_adapter_dart.h +++ b/windows/dart/core_adapter_dart.h @@ -174,6 +174,17 @@ DLL_EXPORT void __stdcall RequestConnectionDart( DLL_EXPORT void __stdcall AcceptConnectionDart( Core *pCore, const char *endpoint_id, PayloadListenerDart listener_dart, Dart_Port result_cb); + +// Disconnects from a remote endpoint. {@link Payload}s can no longer be sent +// to or received from the endpoint after this method is called. +// endpoint_id - The identifier for the remote endpoint to disconnect from. +// result_cb - to access the status of the operation when available. +// Possible status codes include: +// Status::STATUS_OK - finished successfully. +DLL_EXPORT void __stdcall DisconnectFromEndpointDart(Core *pCore, + char *endpoint_id, + Dart_Port result_cb); + // Sends a Payload to a remote endpoint. Payloads can only be sent to remote // endpoints once a notice of connection acceptance has been delivered via // ConnectionListener::onConnectionResult().