use of com.connectsdk.discovery.provider.ssdp.Service in project butter-android by butterproject.
the class DLNAService method resubscribeServices.
public void resubscribeServices() {
resubscriptionTimer = new Timer();
resubscriptionTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
Util.runInBackground(new Runnable() {
@Override
public void run() {
List<Service> serviceList = serviceDescription.getServiceList();
if (serviceList != null) {
for (int i = 0; i < serviceList.size(); i++) {
String eventSubURL = makeControlURL("/", serviceList.get(i).eventSubURL);
if (eventSubURL == null) {
continue;
}
String SID = SIDList.get(serviceList.get(i).serviceType);
try {
HttpConnection connection = HttpConnection.newSubscriptionInstance(new URI("http", "", serviceDescription.getIpAddress(), serviceDescription.getPort(), eventSubURL, "", ""));
connection.setMethod(HttpConnection.Method.SUBSCRIBE);
connection.setHeader("TIMEOUT", "Second-" + TIMEOUT);
connection.setHeader("SID", SID);
connection.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
});
}
}, TIMEOUT / 2 * 1000, TIMEOUT / 2 * 1000);
}
Aggregations