gpg::EndpointDiscoveryListenerHelper

#include <endpoint_discovery_listener_helper.h>

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

摘要

在此对象上配置的回调将按照 Nearby Connections API 中的描述进行调用。未明确设置的回调将不执行任何操作。

构造函数和析构函数

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

公共类型

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_ptrEndpointDiscoveryListenerHelperImpl 构造 EndpointDiscoveryListenerHelper

供 API 内部使用。

SetOnEndpointFoundCallback

EndpointDiscoveryListenerHelper & SetOnEndpointFoundCallback(
  OnEndpointFoundCallback callback
)

设置 OnEndpointFoundCallback。

SetOnEndpointLostCallback

EndpointDiscoveryListenerHelper & SetOnEndpointLostCallback(
  OnEndpointLostCallback callback
)

设置 OnEndpointLostCallback。