Package ej.net

Class PollerConnectivityManager

    • Field Detail

      • INTERNET_CONNECTED

        protected static final NetworkCapabilities INTERNET_CONNECTED
        Capability with internet access.
      • INTERNET_UNCONNECTED

        protected static final NetworkCapabilities INTERNET_UNCONNECTED
        Capability with internet access.
    • Constructor Detail

      • PollerConnectivityManager

        public PollerConnectivityManager()
        Instantiates a PollerConnectivityManager with default periods and delay and a new timer.
      • PollerConnectivityManager

        public PollerConnectivityManager​(Timer timer)
        Instantiates a PollerConnectivityManager with default value.
        Parameters:
        timer - the timer to use, cannot be null.
      • PollerConnectivityManager

        public PollerConnectivityManager​(Timer timer,
                                         long delay,
                                         long period)
        Instantiates a PollerConnectivityManager with the same period when up or not.
        Parameters:
        timer - the timer to use, cannot be null.
        delay - the delay before the start.
        period - the period for the polling.
      • PollerConnectivityManager

        public PollerConnectivityManager​(Timer timer,
                                         long delay,
                                         long periodWhenAvailable,
                                         long periodWhenLost)
        Instantiates a PollerConnectivityManager with the different periods when available or not. The same period is used wth or without internet access when availble.
        Parameters:
        timer - the timer to use, cannot be null.
        delay - the delay before the start.
        periodWhenAvailable - the period for the polling when at least one interface is available.
        periodWhenLost - the period for the polling when all the interface are down.
      • PollerConnectivityManager

        public PollerConnectivityManager​(Timer timer,
                                         long delay,
                                         long periodWhenAvaialble,
                                         long periodWhenLost,
                                         long periodWhenInternet)
        Instantiates a PollerConnectivityManager with the same period when connected or not.
        Parameters:
        timer - the timer to use, cannot be null.
        delay - the delay before the start.
        periodWhenAvaialble - the period for the polling when at least one interface is available.
        periodWhenLost - the period for the polling when all the interface are down.
        periodWhenInternet - the period for the polling when there is internet access.
    • Method Detail

      • startPolling

        public void startPolling​(long delay)
        Starts the polling function.
        Parameters:
        delay - the delay before starting.
      • stopPolling

        public void stopPolling()
        Stops the polling function.
      • cancel

        public void cancel()
        Cancels the associated timer.
      • log

        protected void log​(int msg)
        Logs a message.
        Parameters:
        msg - the message to log.
      • log

        protected void log​(int msg,
                           Throwable t)
        Logs a message and a throwable.
        Parameters:
        msg - the message to log.
        t - a throwable to print, cannot be null.
      • getCapabilities

        protected NetworkCapabilities getCapabilities​(InetAddress connectedAddress)
        Gets the capabilities of a network.
        Parameters:
        connectedAddress - the address to get the capabilities from, cannot be null.
        Returns:
        the capabilities of the address.