Strategy.Builder

public static class Strategy.Builder extends Object

Builder for Strategy.

Public Constructor Summary

Public Method Summary

Strategy
build()
Builds an instance of Strategy.
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

public Strategy.Builder ()

Creates a new Strategy.Builder. By default it will have the same settings as a DEFAULT strategy.

Public Methods

public Strategy build ()

Builds an instance of Strategy.

public Strategy.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 of Strategy.DISCOVERY_MODE_* specifying how to detect nearby devices.

public 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.

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 of Strategy.DISTANCE_TYPE_* specifying how close nearby devices must be.

public Strategy.Builder setTtlSeconds (int ttlSeconds)

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

If not set, TTL_SECONDS_DEFAULT is used instead.