gpg::EndpointDiscoveryListenerHelper

#include <endpoint_discovery_listener_helper.h>

定义一个帮助程序,可用于为 SDK 提供 IEndpointDiscoveryListener 回调,而无需定义完整的 IEndpointDiscoveryListener 接口。

摘要

系统将调用此对象上配置的回调,如 Nearby Connections API 中所述。未明确设置的回调不会执行任何操作。

构造函数和析构函数

EndpointDiscoveryListenerHelper()
EndpointDiscoveryListenerHelper(std::shared_ptr< EndpointDiscoveryListenerHelperImpl > impl)
构造从 shared_ptrEndpointDiscoveryListenerHelperImplEndpointDiscoveryListenerHelper

公共类型

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

公共函数

SetOnEndpointFoundCallback(OnEndpointFoundCallback callback)
设置 OnEndpointFoundCallback。
SetOnEndpointLostCallback(OnEndpointLostCallback callback)
设置 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()

EndpointDiscoveryListenerHelper

 EndpointDiscoveryListenerHelper(
  std::shared_ptr< EndpointDiscoveryListenerHelperImpl > impl
)

构造从 shared_ptrEndpointDiscoveryListenerHelperImplEndpointDiscoveryListenerHelper

供 API 内部使用。

SetOnEndpointFoundCallback

EndpointDiscoveryListenerHelper & SetOnEndpointFoundCallback(
  OnEndpointFoundCallback callback
)

设置 OnEndpointFoundCallback。

SetOnEndpointLostCallback

EndpointDiscoveryListenerHelper & SetOnEndpointLostCallback(
  OnEndpointLostCallback callback
)

设置 OnEndpointLostCallback。