Strategy.Builder

public static classStrategy.BuilderextendsObject

Builder forStrategy.

Public Constructor Summary

Builder()
Creates a new Strategy.Builder.

Public Method Summary

Strategy
build()
Builds an instance ofStrategy.
Strategy.Builder
setDiscoveryMode(int discoveryMode)
Sets the desired discovery mode that determines how devices will detect each other.
Strategy.Builder
setDistanceType(int distanceType)
If used with a publish, the published message will only be delivered to subscribing devices that are at most the specified distance from this device.
Strategy.Builder
setTtlSeconds(int ttlSeconds)
Sets the time to live in seconds for the publish or subscribe.

Inherited Method Summary

Public Constructors

publicBuilder()

Creates a newStrategy.Builder. By default it will have the same settings as aStrategy.DEFAULT strategy.

Public Methods

publicStrategy build()

Builds an instance ofStrategy.

publicStrategy.Builder setDiscoveryMode(int discoveryMode)

Sets the desired discovery mode that determines how devices will detect each other.

The discovery mode is orthogonal to if device is publishing or subscribing for messages. It's just the mechanism for detecting nearby devices. By default, the devices will broadcast and scan for pairing codes, so other devices can detect the originator from either a scan or a broadcast as well or both. Doing both allows for inclusion of devices that can only broadcast.

Parameters
discoveryMode One ofStrategy.DISCOVERY_MODE_*specifying how to detect nearby devices.

publicStrategy.Builder setDistanceType(int distanceType)

If used with a publish, the published message will only be delivered to subscribing devices that are at most the specified distance from this device.

If used with a subscribe, messages will only be delivered if the publishing device is at most the specified distance from this device.

Parameters
distanceType One ofStrategy.DISTANCE_TYPE_*specifying how close nearby devices must be.

publicStrategy.Builder setTtlSeconds(int ttlSeconds)

Sets the time to live in seconds for the publish or subscribe. This must be either Strategy.TTL_SECONDS_INFINITE,or a positive integer between 1 and Strategy.TTL_SECONDS_MAX,inclusive.

If not set, Strategy.TTL_SECONDS_DEFAULTis used instead.