SSDPClient now uses StandardSSDPInfo class publicly
This commit is contained in:
parent
f1e5e17d50
commit
2e476d6689
2 changed files with 13 additions and 11 deletions
18
src/zutil/net/ssdp/SSDPClient.java
Normal file → Executable file
18
src/zutil/net/ssdp/SSDPClient.java
Normal file → Executable file
|
|
@ -48,8 +48,8 @@ import java.util.logging.Logger;
|
|||
public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetworkThread{
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
// Contains all the received services
|
||||
private HashMap<String, LinkedList<SSDPServiceInfo>> services_st;
|
||||
private HashMap<String, SSDPServiceInfo> services_usn;
|
||||
private HashMap<String, LinkedList<StandardSSDPInfo>> services_st;
|
||||
private HashMap<String, StandardSSDPInfo> services_usn;
|
||||
|
||||
private SSDPServiceListener listener;
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
super(null);
|
||||
super.setThread(this);
|
||||
|
||||
services_st = new HashMap<String, LinkedList<SSDPServiceInfo>>();
|
||||
services_usn = new HashMap<String, SSDPServiceInfo>();
|
||||
services_st = new HashMap<>();
|
||||
services_usn = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,7 +86,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
}
|
||||
public void requestService(String st, HashMap<String,String> headers){
|
||||
try {
|
||||
services_st.put( st, new LinkedList<SSDPServiceInfo>() );
|
||||
services_st.put( st, new LinkedList<StandardSSDPInfo>() );
|
||||
|
||||
// Generate an SSDP discover message
|
||||
StringOutputStream msg = new StringOutputStream();
|
||||
|
|
@ -131,7 +131,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
* @param st is the search target
|
||||
* @return a list of received services
|
||||
*/
|
||||
public LinkedList<SSDPServiceInfo> getServices(String st){
|
||||
public LinkedList<StandardSSDPInfo> getServices(String st){
|
||||
return services_st.get( st );
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
* @param usn is the unique identifier for the service
|
||||
* @return an service, null if there is no such service
|
||||
*/
|
||||
public SSDPServiceInfo getService(String usn){
|
||||
public StandardSSDPInfo getService(String usn){
|
||||
return services_usn.get( usn );
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
StandardSSDPInfo service;
|
||||
// Get existing service
|
||||
if( services_usn.containsKey( usn )){
|
||||
service = (StandardSSDPInfo)services_usn.get( usn );
|
||||
service = services_usn.get( usn );
|
||||
}
|
||||
// Add new service
|
||||
else{
|
||||
|
|
@ -195,7 +195,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
|
|||
service = new StandardSSDPInfo();
|
||||
services_usn.put( usn, service);
|
||||
if( !services_st.containsKey(st) )
|
||||
services_st.put( st, new LinkedList<SSDPServiceInfo>() );
|
||||
services_st.put( st, new LinkedList<StandardSSDPInfo>() );
|
||||
services_st.get( header.getHeader("ST") ).add( service );
|
||||
}
|
||||
|
||||
|
|
|
|||
6
src/zutil/net/ssdp/SSDPServiceInfo.java
Normal file → Executable file
6
src/zutil/net/ssdp/SSDPServiceInfo.java
Normal file → Executable file
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
package zutil.net.ssdp;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
/**
|
||||
* This class contains information about a service from
|
||||
* or through the SSDP protocol
|
||||
|
|
@ -33,10 +35,10 @@ package zutil.net.ssdp;
|
|||
public interface SSDPServiceInfo {
|
||||
|
||||
/**
|
||||
* @return The URL to the Service, e.g. "http://192.168.0.1:80/index.html"
|
||||
* @return the URL to the Service, e.g. "http://192.168.0.1:80/index.html"
|
||||
*/
|
||||
public String getLocation();
|
||||
|
||||
|
||||
/**
|
||||
* @return the Search Target, e.g. "upnp:rootdevice"
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue