gpg::NearbyConnections::Builder
#include <nearby_connections_builder.h>
Builder class used to construct NearbyConnections objects.
Summary
Constructors and Destructors |
|
---|---|
Builder()
|
|
~Builder()
|
Public types |
|
---|---|
OnInitializationFinishedCallback
|
typedefstd::function< void(InitializationStatus)>
A callback that the app invokes on initializing the API, or when initialization fails. |
OnLogCallback
|
typedefstd::function< void(LogLevel, const std::string &)>
The type of logging callback that can be provided to the SDK. |
Public functions |
|
---|---|
Create(const PlatformConfiguration & platform)
|
std::unique_ptr< NearbyConnections >
Specifies the platform for which
Builder is to create the NearbyConnections object, and then attempts to create it. |
SetClientId(int64_t client_id)
|
Builder &
Sets a client ID for this API, which are returned by callbacks.
|
SetDefaultOnLog(LogLevel min_level)
|
Builder &
Specifies that logging should use the
DEFAULT_ON_LOG_CALLBACK at the specified log level. |
SetOnInitializationFinished(OnInitializationFinishedCallback callback)
|
Builder &
Registers a callback that the app calls when initialization finishes.
|
SetOnLog(OnLogCallback callback, LogLevel min_level)
|
Builder &
Registers a callback that will perform logging.
|
SetOnLog(OnLogCallback callback)
|
Builder &
Registers a callback that will perform logging.
|
SetServiceId(const std::string & service_id)
|
Builder &
Sets a service ID used when advertising.
|
Public types
OnInitializationFinishedCallback
std::function< void(InitializationStatus)> OnInitializationFinishedCallback
A callback that the app invokes on initializing the API, or when initialization fails.
OnLogCallback
std::function< void(LogLevel, const std::string &)> OnLogCallback
The type of logging callback that can be provided to the SDK.
Public functions
Builder
Builder()
Create
std::unique_ptr< NearbyConnections > Create( const PlatformConfiguration & platform )
Specifies the platform for which Builder
is to create the NearbyConnections
object, and then attempts to create it.
If successful, it will return a unique_ptr
to the NearbyConnections
object. For more information, see the documentation on platform configuration.
SetClientId
Builder & SetClientId( int64_t client_id )
Sets a client ID for this API, which are returned by callbacks.
The client ID allows a single object to register as a listener for multiple NearbyConnection
instances, and to tell which callbacks are being returned for which instances. This ID does nothing on Android.
SetDefaultOnLog
Builder & SetDefaultOnLog( LogLevel min_level )
Specifies that logging should use the DEFAULT_ON_LOG_CALLBACK
at the specified log level.
min_level
specifies the minimum log level at which the app invokes the default callback.
Possible levels are: VERBOSE
, INFO
, WARNING
, and ERROR
.
This specification is equivalent to calling SetOnLog(OnLogCallback, LogLevel)
with OnLogCallback
set to DEFAULT_ON_LOG_CALLBACK
and a LogLevel
of min_level
.
SetOnInitializationFinished
Builder & SetOnInitializationFinished( OnInitializationFinishedCallback callback )
Registers a callback that the app calls when initialization finishes.
The app must call it prior to calling Create
. The app may invoke the callback multiple times. For example, if a user gets a phone call and then returns to the app, NearbyConnections
will reinitialize and then call this callback again.
Note that this callback must be called before you can use a NearbyConnections
object.
SetOnLog
Builder & SetOnLog( OnLogCallback callback, LogLevel min_level )
Registers a callback that will perform logging.
min_level specifies the minimum log level. In ascending order, possible levels are: VERBOSE
, INFO
, WARNING
, and ERROR
.
SetOnLog
Builder & SetOnLog( OnLogCallback callback )
Registers a callback that will perform logging.
This is equivalent to calling SetOnLog(OnLogCallback, LogLevel)
with a LogLevel of INFO
.
SetServiceId
Builder & SetServiceId( const std::string & service_id )
Sets a service ID used when advertising.
This ID does nothing on Android, but other platforms may require it to be able to advertise.
~Builder
~Builder()