Class DirectoryThread

Package: io.keychain.util

public class DirectoryThread implements Runnable
extends java.lang.Object

Description

The DirectoryThread is a Runnable that can be used in concert with the PairHelper to create a polling interface to the Keychain-hosted sample Trusted Directory.

While this class has 3 public methods, only onStop() should be called directly. The other two are called via Runnable#start(). Treat this class like a Runnable and everything is smooth.

As of v2.4, the refresh time is fixed at 11 seconds. In future versions this will be configurable.

Since: v2.0

Public Constructors

Constructor

DirectoryThread(Gateway gateway, PairHelper pairHelper)

Creates a new DirectoryThread that will use the provided PairHelper to communicate to the TD and read/write data via the provided Gateway

Public Member Functions

Return type Method and Description

void

doContactSync()

The main action method which asks PairHelper to get all Uris and adds them as Contacts, then also uploads its own active Persona

void

run()

Begins execution - never call directly

void

onStop()

Tells the thread to stop

Public Member Functions Detail

doContactSync

void doContactSync()

The main workhorse of DirectoryThread. Do not invoke this directly. Let run() call it as necessary.

run

void run()

As a Runnable, this method must be overridden and is what is executed when Runnable#start() is invoked. It basically kicks off a loop that periodically calls doContactSync() until onStop() is called by the user.

onStop

void onStop()

Tells this thread to stop executing. It will set the stop flag and return almost instantly.