使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
gpg::EndpointDiscoveryListenerHelper
#include <endpoint_discovery_listener_helper.h>
定义了一个辅助程序,可用于向 SDK 提供 IEndpointDiscoveryListener 回调,而无需定义完整的 IEndpointDiscoveryListener 接口。
摘要
系统会调用在此对象上配置的回调,如 Nearby Connections API 中所述。未明确设置的回调将不执行任何操作。
公共类型
|
OnEndpointFoundCallback
|
typedef
std::function< void(int64_t client_id, const EndpointDetails &endpoint_details)>
找到远程端点时,系统会调用 OnEndpointFoundCallback 。 |
OnEndpointLostCallback
|
typedef
std::function< void(int64_t client_id, const std::string &remote_endpoint_id)>
当远程端点无法再被发现时,系统会调用 OnEndpointLostCallback 。 |
公共类型
OnEndpointFoundCallback
std::function< void(int64_t client_id, const EndpointDetails &endpoint_details)> OnEndpointFoundCallback
找到远程端点时,系统会调用 OnEndpointFoundCallback
。
client_id
是发现端点的 NearbyConnections 实例的 ID。endpoint_details
包含发现的远程端点的详细信息。
OnEndpointLostCallback
std::function< void(int64_t client_id, const std::string &remote_endpoint_id)> OnEndpointLostCallback
当远程端点无法再被发现时,系统会调用 OnEndpointLostCallback
。
公共函数
EndpointDiscoveryListenerHelper
EndpointDiscoveryListenerHelper()
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# gpg::EndpointDiscoveryListenerHelper Class Reference\n\ngpg::EndpointDiscoveryListenerHelper\n====================================\n\n`#include \u003cendpoint_discovery_listener_helper.h\u003e`\n\nDefines a helper which can be used to provide [IEndpointDiscoveryListener](/games/services/cpp/api/class/gpg/i-endpoint-discovery-listener#classgpg_1_1_i_endpoint_discovery_listener) callbacks to the SDK without defining the full [IEndpointDiscoveryListener](/games/services/cpp/api/class/gpg/i-endpoint-discovery-listener#classgpg_1_1_i_endpoint_discovery_listener) interface.\n\nSummary\n-------\n\nCallbacks configured on this object will be invoked as described in the nearby connections API. Callbacks not explicitly set will do nothing.\n\n| ### Constructors and Destructors ||\n|---|---|\n| [EndpointDiscoveryListenerHelper](#classgpg_1_1_endpoint_discovery_listener_helper_1ad33271ad25ee20072d78a2eeda900209)`()` ||\n| [EndpointDiscoveryListenerHelper](#classgpg_1_1_endpoint_discovery_listener_helper_1a575bde82a9754f7a37540f516431ac31)`(std::shared_ptr\u003c `[EndpointDiscoveryListenerHelperImpl](/games/services/cpp/api/class/gpg/endpoint-discovery-listener-helper#classgpg_1_1_endpoint_discovery_listener_helper_1a11c2430f8609135c8c5ae7ad84df9a4e)` \u003e impl)` Constructs a [EndpointDiscoveryListenerHelper](/games/services/cpp/api/class/gpg/endpoint-discovery-listener-helper#classgpg_1_1_endpoint_discovery_listener_helper) from a `shared_ptr` to a `EndpointDiscoveryListenerHelperImpl`. ||\n\n| ### Public types ||\n|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [OnEndpointFoundCallback](#classgpg_1_1_endpoint_discovery_listener_helper_1a2db162a39aeb28dcf620a9a7f2ebf55e) | typedef `std::function\u003c void(int64_t client_id, const `[EndpointDetails](/games/services/cpp/api/struct/gpg/endpoint-details#structgpg_1_1_endpoint_details)` &endpoint_details)\u003e` `OnEndpointFoundCallback` is called when a remote endpoint is found. |\n| [OnEndpointLostCallback](#classgpg_1_1_endpoint_discovery_listener_helper_1a74269018f38766d3164b66df7dac0000) | typedef `std::function\u003c void(int64_t client_id, const std::string &remote_endpoint_id)\u003e` `OnEndpointLostCallback` is called when a remote endpoint is no longer discoverable. |\n\n| ### Public functions ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [SetOnEndpointFoundCallback](#classgpg_1_1_endpoint_discovery_listener_helper_1ac3228d952cf2f7152f4b5e78407885da)`(`[OnEndpointFoundCallback](/games/services/cpp/api/class/gpg/endpoint-discovery-listener-helper#classgpg_1_1_endpoint_discovery_listener_helper_1a2db162a39aeb28dcf620a9a7f2ebf55e)` callback)` | [EndpointDiscoveryListenerHelper](/games/services/cpp/api/class/gpg/endpoint-discovery-listener-helper#classgpg_1_1_endpoint_discovery_listener_helper)` &` Set the OnEndpointFoundCallback. |\n| [SetOnEndpointLostCallback](#classgpg_1_1_endpoint_discovery_listener_helper_1a40e1bc52ca32cb2dcab6808a7050b0d1)`(`[OnEndpointLostCallback](/games/services/cpp/api/class/gpg/endpoint-discovery-listener-helper#classgpg_1_1_endpoint_discovery_listener_helper_1a74269018f38766d3164b66df7dac0000)` callback)` | [EndpointDiscoveryListenerHelper](/games/services/cpp/api/class/gpg/endpoint-discovery-listener-helper#classgpg_1_1_endpoint_discovery_listener_helper)` &` Set the OnEndpointLostCallback. |\n\nPublic types\n------------\n\n### OnEndpointFoundCallback\n\n```c++\nstd::function\u003c void(int64_t client_id, const EndpointDetails &endpoint_details)\u003e OnEndpointFoundCallback\n``` \n`OnEndpointFoundCallback` is called when a remote endpoint is found.\n\n`client_id` is the ID of the [NearbyConnections](/games/services/cpp/api/class/gpg/nearby-connections#classgpg_1_1_nearby_connections) instance that discovered the endpoint. `endpoint_details` contains the details of the discovered remote endpoint. \n\n### OnEndpointLostCallback\n\n```c++\nstd::function\u003c void(int64_t client_id, const std::string &remote_endpoint_id)\u003e OnEndpointLostCallback\n``` \n`OnEndpointLostCallback` is called when a remote endpoint is no longer discoverable.\n\nPublic functions\n----------------\n\n### EndpointDiscoveryListenerHelper\n\n```c++\n EndpointDiscoveryListenerHelper()\n``` \n\n### EndpointDiscoveryListenerHelper\n\n```c++\n EndpointDiscoveryListenerHelper(\n std::shared_ptr\u003c EndpointDiscoveryListenerHelperImpl \u003e impl\n)\n``` \nConstructs a [EndpointDiscoveryListenerHelper](/games/services/cpp/api/class/gpg/endpoint-discovery-listener-helper#classgpg_1_1_endpoint_discovery_listener_helper) from a `shared_ptr` to a `EndpointDiscoveryListenerHelperImpl`.\n\nIntended for internal use by the API. \n\n### SetOnEndpointFoundCallback\n\n```c++\nEndpointDiscoveryListenerHelper & SetOnEndpointFoundCallback(\n OnEndpointFoundCallback callback\n)\n``` \nSet the OnEndpointFoundCallback. \n\n### SetOnEndpointLostCallback\n\n```c++\nEndpointDiscoveryListenerHelper & SetOnEndpointLostCallback(\n OnEndpointLostCallback callback\n)\n``` \nSet the OnEndpointLostCallback."]]