SSDPClient now uses StandardSSDPInfo class publicly

This commit is contained in:
Ziver Koc 2015-10-27 17:19:43 +01:00 committed by Ziver Koc
parent f1e5e17d50
commit 2e476d6689
2 changed files with 13 additions and 11 deletions

18
src/zutil/net/ssdp/SSDPClient.java Normal file → Executable file
View file

@ -48,8 +48,8 @@ import java.util.logging.Logger;
public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetworkThread{ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetworkThread{
private static final Logger logger = LogUtil.getLogger(); private static final Logger logger = LogUtil.getLogger();
// Contains all the received services // Contains all the received services
private HashMap<String, LinkedList<SSDPServiceInfo>> services_st; private HashMap<String, LinkedList<StandardSSDPInfo>> services_st;
private HashMap<String, SSDPServiceInfo> services_usn; private HashMap<String, StandardSSDPInfo> services_usn;
private SSDPServiceListener listener; private SSDPServiceListener listener;
@ -64,8 +64,8 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
super(null); super(null);
super.setThread(this); super.setThread(this);
services_st = new HashMap<String, LinkedList<SSDPServiceInfo>>(); services_st = new HashMap<>();
services_usn = new HashMap<String, SSDPServiceInfo>(); services_usn = new HashMap<>();
} }
/** /**
@ -86,7 +86,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
} }
public void requestService(String st, HashMap<String,String> headers){ public void requestService(String st, HashMap<String,String> headers){
try { try {
services_st.put( st, new LinkedList<SSDPServiceInfo>() ); services_st.put( st, new LinkedList<StandardSSDPInfo>() );
// Generate an SSDP discover message // Generate an SSDP discover message
StringOutputStream msg = new StringOutputStream(); StringOutputStream msg = new StringOutputStream();
@ -131,7 +131,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
* @param st is the search target * @param st is the search target
* @return a list of received services * @return a list of received services
*/ */
public LinkedList<SSDPServiceInfo> getServices(String st){ public LinkedList<StandardSSDPInfo> getServices(String st){
return services_st.get( 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 * @param usn is the unique identifier for the service
* @return an service, null if there is no such 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 ); return services_usn.get( usn );
} }
@ -187,7 +187,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
StandardSSDPInfo service; StandardSSDPInfo service;
// Get existing service // Get existing service
if( services_usn.containsKey( usn )){ if( services_usn.containsKey( usn )){
service = (StandardSSDPInfo)services_usn.get( usn ); service = services_usn.get( usn );
} }
// Add new service // Add new service
else{ else{
@ -195,7 +195,7 @@ public class SSDPClient extends ThreadedUDPNetwork implements ThreadedUDPNetwork
service = new StandardSSDPInfo(); service = new StandardSSDPInfo();
services_usn.put( usn, service); services_usn.put( usn, service);
if( !services_st.containsKey(st) ) 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 ); services_st.get( header.getHeader("ST") ).add( service );
} }

6
src/zutil/net/ssdp/SSDPServiceInfo.java Normal file → Executable file
View file

@ -24,6 +24,8 @@
package zutil.net.ssdp; package zutil.net.ssdp;
import java.net.InetAddress;
/** /**
* This class contains information about a service from * This class contains information about a service from
* or through the SSDP protocol * or through the SSDP protocol
@ -33,10 +35,10 @@ package zutil.net.ssdp;
public interface SSDPServiceInfo { 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(); public String getLocation();
/** /**
* @return the Search Target, e.g. "upnp:rootdevice" * @return the Search Target, e.g. "upnp:rootdevice"
*/ */