Class GatewayDiscover


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

      Fields 
      Modifier and Type Field Description
      static java.lang.String IP
      The broadcast address to use when trying to contact UPnP devices
      static int PORT
      The SSDP port
    • Constructor Summary

      Constructors 
      Constructor Description
      GatewayDiscover()
      Constructor.
      GatewayDiscover​(java.lang.String st)
      Constructor of the gateway discover service.
      GatewayDiscover​(java.lang.String[] types)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.net.InetAddress,​GatewayDevice> discover()
      Discovers Gateway Devices on the network(s) the executing machine is connected to.
      java.util.Map<java.net.InetAddress,​GatewayDevice> getAllGateways()
      Returns list of all discovered gateways.
      int getTimeout()
      Gets the timeout for socket connections of the initial broadcast request.
      GatewayDevice getValidGateway()
      Gets the first connected gateway
      void setTimeout​(int milliseconds)
      Sets the timeout for socket connections of the initial broadcast request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • IP

        public static final java.lang.String IP
        The broadcast address to use when trying to contact UPnP devices
        See Also:
        Constant Field Values
    • Constructor Detail

      • GatewayDiscover

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

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

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

      • 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

        public java.util.Map<java.net.InetAddress,​GatewayDevice> discover()
                                                                         throws java.net.SocketException,
                                                                                java.net.UnknownHostException,
                                                                                java.io.IOException,
                                                                                org.xml.sax.SAXException,
                                                                                javax.xml.parsers.ParserConfigurationException
        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:
        java.net.SocketException
        java.net.UnknownHostException
        java.io.IOException
        org.xml.sax.SAXException
        javax.xml.parsers.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 java.util.Map<java.net.InetAddress,​GatewayDevice> getAllGateways()
        Returns list of all discovered gateways. Is empty when no gateway is found.