public class BeaconSender
extends java.lang.Object
The BeaconSender manages the thread running OpenKit communication in the background.
| Constructor and Description |
|---|
BeaconSender(Logger logger,
HTTPClientConfiguration httpClientConfiguration,
HTTPClientProvider clientProvider,
TimingProvider timingProvider)
Create a new BeaconSender.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSession(SessionImpl session)
Adds the given session to the known sessions of this
BeaconSender. |
int |
getCurrentServerId()
Returns the current server ID to be used for creating new sessions
|
ServerConfiguration |
getLastServerConfiguration()
Returns the last known server configuration.
|
void |
initialize()
Start beacon sender thread.
|
boolean |
isInitialized()
Get a boolean indicating whether OpenKit has been initialized or not.
|
void |
shutdown()
Shutdown the BeaconSender and wait until it's shutdown (at most
SHUTDOWN_TIMEOUT milliseconds. |
boolean |
waitForInit()
Wait until OpenKit is fully initialized or a shutdown request has been made.
|
boolean |
waitForInit(long timeoutMillis)
Wait until OpenKit is fully initialized or a shutdown request has been made or given timeout expired.
|
public BeaconSender(Logger logger, HTTPClientConfiguration httpClientConfiguration, HTTPClientProvider clientProvider, TimingProvider timingProvider)
To start the beacon sending the initialize() method must be called.
logger - Logger for logging messageshttpClientConfiguration - Initial HTTP client configuration.clientProvider - Used for retrieving an HTTPClient instance.timingProvider - Used for some timing related things.public void initialize()
Note: The beacon sender has to perform some initialization code, which is done in the background,
before it actually starts sending beacons.
If it's necessary to have OpenKit fully initialized use the waitForInit() method to wait until initialized.
public boolean waitForInit()
This method might hang forever.
true if OpenKit is fully initialized, or false if shutdown has been requested during init phase.public boolean waitForInit(long timeoutMillis)
timeoutMillis - The maximum number of milliseconds to wait for initialization being completed.true if OpenKit is fully initialized, or false if shutdown has been requested during init phase.public boolean isInitialized()
true if OpenKit has been initialized, false otherwise.public void shutdown()
SHUTDOWN_TIMEOUT milliseconds.public ServerConfiguration getLastServerConfiguration()
public int getCurrentServerId()
public void addSession(SessionImpl session)
BeaconSender.
This method should be called when creating a new session.
session - the session to start.