Class BeaconSender


  • public class BeaconSender
    extends java.lang.Object
    The BeaconSender is responsible for asynchronously sending the Beacons to the provided endpoint.

    The BeaconSender manages the thread running OpenKit communication in the background.

    • Constructor Detail

      • BeaconSender

        public BeaconSender​(Logger logger,
                            HTTPClientConfiguration httpClientConfiguration,
                            HTTPClientProvider clientProvider,
                            TimingProvider timingProvider)
        Create a new BeaconSender.

        To start the beacon sending the initialize() method must be called.

        Parameters:
        logger - Logger for logging messages
        httpClientConfiguration - Initial HTTP client configuration.
        clientProvider - Used for retrieving an HTTPClient instance.
        timingProvider - Used for some timing related things.
    • Method Detail

      • initialize

        public void initialize()
        Start beacon sender thread.

        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.

      • waitForInit

        public boolean waitForInit()
        Wait until OpenKit is fully initialized or a shutdown request has been made.

        This method might hang forever.

        Returns:
        true if OpenKit is fully initialized, or false if shutdown has been requested during init phase.
      • waitForInit

        public boolean waitForInit​(long timeoutMillis)
        Wait until OpenKit is fully initialized or a shutdown request has been made or given timeout expired.
        Parameters:
        timeoutMillis - The maximum number of milliseconds to wait for initialization being completed.
        Returns:
        true if OpenKit is fully initialized, or false if shutdown has been requested during init phase.
      • isInitialized

        public boolean isInitialized()
        Get a boolean indicating whether OpenKit has been initialized or not.
        Returns:
        true if OpenKit has been initialized, false otherwise.
      • shutdown

        public void shutdown()
        Shutdown the BeaconSender and wait until it's shutdown (at most SHUTDOWN_TIMEOUT milliseconds.
      • getLastServerConfiguration

        public ServerConfiguration getLastServerConfiguration()
        Returns the last known server configuration.
      • getCurrentServerId

        public int getCurrentServerId()
        Returns the current server ID to be used for creating new sessions
      • addSession

        public void addSession​(SessionImpl session)
        Adds the given session to the known sessions of this BeaconSender.

        This method should be called when creating a new session.

        Parameters:
        session - the session to start.