Class GatewayDiscover

java.lang.Object
org.bitlet.weupnp.GatewayDiscover

public class GatewayDiscover extends Object
Handles the discovery of GatewayDevices, via the discover() method.
  • Field Details

  • Constructor Details

    • GatewayDiscover

      public GatewayDiscover()
      Constructor. By default it's looking for 3 types of gateways.
    • GatewayDiscover

      public GatewayDiscover(String st)
      Constructor of the gateway discover service.
      Parameters:
      st - The search type you are looking for
    • GatewayDiscover

      public GatewayDiscover(String[] types)
      Constructor.
      Parameters:
      types - The search types the discover have to look for
  • Method Details

    • getTimeout

      public int getTimeout()
      Gets the timeout for socket connections of the initial broadcast request.
      Returns:
      timeout in milliseconds
    • setTimeout

      public void setTimeout(int milliseconds)
      Sets the timeout for socket connections of the initial broadcast request.
      Parameters:
      milliseconds - the new timeout in milliseconds
    • discover

      Discovers Gateway Devices on the network(s) the executing machine is connected to.

      The host may be connected to different networks via different network interfaces. Assumes that each network interface has a different InetAddress and returns a map associating every GatewayDevice (responding to a broadcast discovery message) with the InetAddress it is connected to.

      Returns:
      a map containing a GatewayDevice per InetAddress
      Throws:
      SocketException
      UnknownHostException
      IOException
      SAXException
      ParserConfigurationException
    • getValidGateway

      public GatewayDevice getValidGateway()
      Gets the first connected gateway
      Returns:
      the first GatewayDevice which is connected to the network, or null if none present
    • getAllGateways

      public Map<InetAddress,GatewayDevice> getAllGateways()
      Returns list of all discovered gateways. Is empty when no gateway is found.