Java源码示例:org.jupnp.model.message.UpnpResponse
示例1
@Override
protected void failed(GENASubscription subscription, UpnpResponse response, Exception e, String defaultMsg) {
Device deviceRoot = subscription.getService().getDevice().getRoot();
String serviceId = subscription.getService().getServiceId().getId();
logger.debug("A GENA subscription '{}' for device '{}' failed", serviceId,
deviceRoot.getIdentity().getUdn());
for (UpnpIOParticipant participant : participants) {
if (Objects.equals(getDevice(participant), deviceRoot)) {
try {
participant.onServiceSubscribed(serviceId, false);
} catch (Exception e2) {
logger.error("Participant threw an exception onServiceSubscribed", e2);
}
}
}
}
示例2
@Override
protected void failed(GENASubscription subscription, UpnpResponse response, Exception e, String defaultMsg) {
Device deviceRoot = subscription.getService().getDevice().getRoot();
String serviceId = subscription.getService().getServiceId().getId();
logger.debug("A GENA subscription '{}' for device '{}' failed", serviceId,
deviceRoot.getIdentity().getUdn());
for (UpnpIOParticipant participant : participants) {
if (Objects.equals(getDevice(participant), deviceRoot)) {
try {
participant.onServiceSubscribed(serviceId, false);
} catch (Exception e2) {
logger.error("Participant threw an exception onServiceSubscribed", e2);
}
}
}
}
示例3
@Override
protected Callable<StreamResponseMessage> createCallable(
final StreamRequestMessage requestMessage, final Call call) {
return () -> {
final Response httpResponse = call.execute();
final UpnpResponse upnpResponse =
new UpnpResponse(httpResponse.code(), httpResponse.message());
final StreamResponseMessage streamResponseMessage = new StreamResponseMessage(upnpResponse);
streamResponseMessage.setHeaders(new UpnpHeaders(httpResponse.headers().toMultimap()));
streamResponseMessage.setBodyCharacters(httpResponse.body().bytes());
return streamResponseMessage;
};
}
示例4
@Override
protected void ended(GENASubscription subscription, CancelReason reason, UpnpResponse response) {
final Service service = subscription.getService();
if (service != null) {
final ServiceId serviceId = service.getServiceId();
final Device device = service.getDevice();
if (device != null) {
final Device deviceRoot = device.getRoot();
if (deviceRoot != null) {
final DeviceIdentity deviceRootIdentity = deviceRoot.getIdentity();
if (deviceRootIdentity != null) {
final UDN deviceRootUdn = deviceRootIdentity.getUdn();
logger.debug("A GENA subscription '{}' for device '{}' was ended", serviceId.getId(),
deviceRootUdn);
}
}
}
if ((CancelReason.EXPIRED.equals(reason) || CancelReason.RENEWAL_FAILED.equals(reason))
&& upnpService != null) {
final ControlPoint cp = upnpService.getControlPoint();
if (cp != null) {
final UpnpSubscriptionCallback callback = new UpnpSubscriptionCallback(service,
subscription.getActualDurationSeconds());
cp.execute(callback);
}
}
}
}
示例5
@Override
protected void ended(GENASubscription subscription, CancelReason reason, UpnpResponse response) {
final Service service = subscription.getService();
if (service != null) {
final ServiceId serviceId = service.getServiceId();
final Device device = service.getDevice();
if (device != null) {
final Device deviceRoot = device.getRoot();
if (deviceRoot != null) {
final DeviceIdentity deviceRootIdentity = deviceRoot.getIdentity();
if (deviceRootIdentity != null) {
final UDN deviceRootUdn = deviceRootIdentity.getUdn();
logger.debug("A GENA subscription '{}' for device '{}' was ended", serviceId.getId(),
deviceRootUdn);
}
}
}
if ((CancelReason.EXPIRED.equals(reason) || CancelReason.RENEWAL_FAILED.equals(reason))
&& upnpService != null) {
final ControlPoint cp = upnpService.getControlPoint();
if (cp != null) {
final UpnpSubscriptionCallback callback = new UpnpSubscriptionCallback(service,
subscription.getActualDurationSeconds());
cp.execute(callback);
}
}
}
}