Search in sources :

Example 6 with ServiceDescription

use of com.connectsdk.service.config.ServiceDescription in project butter-android by butterproject.

the class SSDPDiscoveryProvider method sendSearch.

public void sendSearch() {
    List<String> killKeys = new ArrayList<String>();
    long killPoint = new Date().getTime() - TIMEOUT;
    for (String key : foundServices.keySet()) {
        ServiceDescription service = foundServices.get(key);
        if (service == null || service.getLastDetection() < killPoint) {
            killKeys.add(key);
        }
    }
    for (String key : killKeys) {
        final ServiceDescription service = foundServices.get(key);
        if (service != null) {
            notifyListenersOfLostService(service);
        }
        if (foundServices.containsKey(key))
            foundServices.remove(key);
    }
    rescan();
}
Also used : ServiceDescription(com.connectsdk.service.config.ServiceDescription) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Date(java.util.Date)

Aggregations

ServiceDescription (com.connectsdk.service.config.ServiceDescription)6 DiscoveryProviderListener (com.connectsdk.discovery.DiscoveryProviderListener)2 Date (java.util.Date)2 ServiceConfig (com.connectsdk.service.config.ServiceConfig)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Matcher (java.util.regex.Matcher)1 JSONObject (org.json.JSONObject)1