Package ej.net

Class HttpPollerConnectivityManager


  • public class HttpPollerConnectivityManager
    extends PollerConnectivityManager
    Basic full java implementation. Consider the network is connected when there is at least one NetworkInterface which address is not 0.0.0.0. It uses an HTTP request to check if it is connected to internet.
    • Field Detail

      • PROPERTY_PORT

        public static final java.lang.String PROPERTY_PORT
        Property used to define the port.
        See Also:
        Constant Field Values
      • PROPERTY_HOST

        public static final java.lang.String PROPERTY_HOST
        Property used to define the host.
        See Also:
        Constant Field Values
      • PROPERTY_PAYLOAD

        public static final java.lang.String PROPERTY_PAYLOAD
        Property used to define the payload.
        See Also:
        Constant Field Values
    • Constructor Detail

      • HttpPollerConnectivityManager

        public HttpPollerConnectivityManager()
        Instantiates an HttpPollerConnectivityManager with System properties values.

        It uses the system properties:

        • connectivity.http.host
        • connectivity.http.port (optional default value is 80)
        • connectivity.http.payload (optional default value will do a get at the root of the host)
        See Also:
        PollerConnectivityManager()
      • HttpPollerConnectivityManager

        public HttpPollerConnectivityManager​(ej.bon.Timer timer)
        Instantiates an HttpPollerConnectivityManager with System properties values.

        It uses the system properties:

        • connectivity.http.host
        • connectivity.http.port (optional default value is 80)
        • connectivity.http.payload (optional default value will do a get at the root of the host)
        Parameters:
        timer - the timer to use, cannot be null.
        See Also:
        PollerConnectivityManager()
      • HttpPollerConnectivityManager

        public HttpPollerConnectivityManager​(ej.bon.Timer timer,
                                             long delay,
                                             long periodWhenAvaialble,
                                             long periodWhenLost,
                                             long periodWhenInternet)
        Instantiates an HttpPollerConnectivityManager with arguments values.
        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

      • setHttpValues

        public void setHttpValues​(@Nullable
                                  java.lang.String host,
                                  @Nullable
                                  java.lang.String payload,
                                  int port)
        Sets the http values.
        Parameters:
        host - the host to use, cannot be null.
        payload - the payload to send, if null a simple get request at the root will be used.
        port - the port to use.
      • getCapabilities

        protected android.net.NetworkCapabilities getCapabilities​(java.net.InetAddress localAddress)
        Description copied from class: PollerConnectivityManager
        Gets the capabilities of a network. Isolate for testing.
        Overrides:
        getCapabilities in class PollerConnectivityManager
        Parameters:
        localAddress - the address to get the capabilities from, cannot be null.
        Returns:
        the capabilities of the address.