Package org.bitlet.weupnp
Class GatewayDiscover
- java.lang.Object
-
- org.bitlet.weupnp.GatewayDiscover
-
public class GatewayDiscover extends java.lang.Object
Handles the discovery of GatewayDevices, via thediscover()
method.
-
-
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 gatewayvoid
setTimeout(int milliseconds)
Sets the timeout for socket connections of the initial broadcast request.
-
-
-
Field Detail
-
PORT
public static final int PORT
The SSDP port- See Also:
- Constant Field Values
-
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.
-
-