@Override public void onWakeupClicked() { try { upnpService.getRouter().broadcast(wakeOnLANBytes); } catch (RouterException ex) { Workbench.Log.MAIN.warning( "Broadcasting wakeup bytes on LAN failed: " + ex ); } }
case 0: if (upnpService != null) { Router router = upnpService.get().getRouter(); try { if (router.isEnabled()) {
protected StreamResponseMessage executeSync() throws RouterException { log.fine("Sending event for subscription: " + subscriptionId); StreamResponseMessage lastResponse = null; for (OutgoingEventRequestMessage requestMessage : requestMessages) { if (currentSequence.getValue() == 0) { log.fine("Sending initial event message to callback URL: " + requestMessage.getUri()); } else { log.fine("Sending event message '"+currentSequence+"' to callback URL: " + requestMessage.getUri()); } // Send request lastResponse = getUpnpService().getRouter().send(requestMessage); log.fine("Received event callback response: " + lastResponse); } // It's not really used, so just return the last one - we have only one callback URL most of the // time anyway return lastResponse; } }
protected StreamResponseMessage executeSync() throws RouterException { log.fine("Sending unsubscribe request: " + getInputMessage()); StreamResponseMessage response = null; try { response = getUpnpService().getRouter().send(getInputMessage()); return response; } finally { onUnsubscribe(response); } }
Router router = upnpService.get().getRouter(); try { if (router.isEnabled()) {
protected StreamResponseMessage sendRemoteRequest(OutgoingActionRequestMessage requestMessage) throws ActionException, RouterException { try { log.fine("Writing SOAP request body of: " + requestMessage); getUpnpService().getConfiguration().getSoapActionProcessor().writeBody(requestMessage, actionInvocation); log.fine("Sending SOAP body of message as stream to remote device"); return getUpnpService().getRouter().send(requestMessage); } catch (RouterException ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { if (log.isLoggable(Level.FINE)) { log.fine("Sending action request message was interrupted: " + cause); } throw new ActionCancelledException((InterruptedException)cause); } throw ex; } catch (UnsupportedDataException ex) { if (log.isLoggable(Level.FINE)) { log.fine("Error writing SOAP body: " + ex); log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex)); } throw new ActionException(ErrorCode.ACTION_FAILED, "Error writing request message. " + ex.getMessage()); } }
protected void execute() throws RouterException { if (getUpnpService().getRouter() == null) { // TODO: http://mailinglists.945824.n3.nabble.com/rare-NPE-on-start-tp3078213p3142767.html log.fine("Router hasn't completed initialization, ignoring received search message"); return; } if (!getInputMessage().isMANSSDPDiscover()) { log.fine("Invalid search request, no or invalid MAN ssdp:discover header: " + getInputMessage()); return; } UpnpHeader searchTarget = getInputMessage().getSearchTarget(); if (searchTarget == null) { log.fine("Invalid search request, did not contain ST header: " + getInputMessage()); return; } List<NetworkAddress> activeStreamServers = getUpnpService().getRouter().getActiveStreamServers(getInputMessage().getLocalAddress()); if (activeStreamServers.size() == 0) { log.fine("Aborting search response, no active stream servers found (network disabled?)"); return; } for (NetworkAddress activeStreamServer : activeStreamServers) { sendResponses(searchTarget, activeStreamServer); } }
protected void execute() throws RouterException { List<NetworkAddress> activeStreamServers = getUpnpService().getRouter().getActiveStreamServers(null); if (activeStreamServers.size() == 0) { log.fine("Aborting notifications, no active stream servers found (network disabled?)"); return; } // Prepare it once, it's the same for each repetition List<Location> descriptorLocations = new ArrayList<>(); for (NetworkAddress activeStreamServer : activeStreamServers) { descriptorLocations.add( new Location( activeStreamServer, getUpnpService().getConfiguration().getNamespace().getDescriptorPathString(getDevice()) ) ); } for (int i = 0; i < getBulkRepeat(); i++) { try { for (Location descriptorLocation : descriptorLocations) { sendMessages(descriptorLocation); } // UDA 1.0 is silent about this but UDA 1.1 recomments "a few hundred milliseconds" log.finer("Sleeping " + getBulkIntervalMilliseconds() + " milliseconds"); Thread.sleep(getBulkIntervalMilliseconds()); } catch (InterruptedException ex) { log.warning("Advertisement thread was interrupted: " + ex); } } }
protected void execute() throws RouterException { log.fine("Executing search for target: " + searchTarget.getString() + " with MX seconds: " + getMxSeconds()); OutgoingSearchRequest msg = new OutgoingSearchRequest(searchTarget, getMxSeconds()); prepareOutgoingSearchRequest(msg); for (int i = 0; i < getBulkRepeat(); i++) { try { getUpnpService().getRouter().send(msg); // UDA 1.0 is silent about this but UDA 1.1 recommends "a few hundred milliseconds" log.finer("Sleeping " + getBulkIntervalMilliseconds() + " milliseconds"); Thread.sleep(getBulkIntervalMilliseconds()); } catch (InterruptedException ex) { // Interruption means we stop sending search messages, e.g. on shutdown of thread pool break; } } }
public void sendMessages(Location descriptorLocation) throws RouterException { log.finer("Sending root device messages: " + getDevice()); List<OutgoingNotificationRequest> rootDeviceMsgs = createDeviceMessages(getDevice(), descriptorLocation); for (OutgoingNotificationRequest upnpMessage : rootDeviceMsgs) { getUpnpService().getRouter().send(upnpMessage); } if (getDevice().hasEmbeddedDevices()) { for (LocalDevice embeddedDevice : getDevice().findEmbeddedDevices()) { log.finer("Sending embedded device messages: " + embeddedDevice); List<OutgoingNotificationRequest> embeddedDeviceMsgs = createDeviceMessages(embeddedDevice, descriptorLocation); for (OutgoingNotificationRequest upnpMessage : embeddedDeviceMsgs) { getUpnpService().getRouter().send(upnpMessage); } } } List<OutgoingNotificationRequest> serviceTypeMsgs = createServiceTypeMessages(getDevice(), descriptorLocation); if (serviceTypeMsgs.size() > 0) { log.finer("Sending service type messages"); for (OutgoingNotificationRequest upnpMessage : serviceTypeMsgs) { getUpnpService().getRouter().send(upnpMessage); } } }
createDeviceMessages(localDevice, activeStreamServer); for (OutgoingSearchResponse upnpMessage : rootDeviceMsgs) { getUpnpService().getRouter().send(upnpMessage); createDeviceMessages(embeddedDevice, activeStreamServer); for (OutgoingSearchResponse upnpMessage : embeddedDeviceMsgs) { getUpnpService().getRouter().send(upnpMessage); getUpnpService().getRouter().send(upnpMessage);
protected void sendSearchResponseServiceType(ServiceType serviceType, NetworkAddress activeStreamServer) throws RouterException { log.fine("Responding to service type search: " + serviceType); Collection<Device> devices = getUpnpService().getRegistry().getDevices(serviceType); for (Device device : devices) { if (device instanceof LocalDevice) { if (isAdvertisementDisabled((LocalDevice)device)) continue; log.finer("Sending matching service type search result: " + device); OutgoingSearchResponse message = new OutgoingSearchResponseServiceType( getInputMessage(), getDescriptorLocation(activeStreamServer, (LocalDevice) device), (LocalDevice) device, serviceType ); prepareOutgoingSearchResponse(message); getUpnpService().getRouter().send(message); } } }
protected void sendSearchResponseDeviceType(DeviceType deviceType, NetworkAddress activeStreamServer) throws RouterException{ log.fine("Responding to device type search: " + deviceType); Collection<Device> devices = getUpnpService().getRegistry().getDevices(deviceType); for (Device device : devices) { if (device instanceof LocalDevice) { if (isAdvertisementDisabled((LocalDevice)device)) continue; log.finer("Sending matching device type search result for: " + device); OutgoingSearchResponse message = new OutgoingSearchResponseDeviceType( getInputMessage(), getDescriptorLocation(activeStreamServer, (LocalDevice) device), (LocalDevice) device ); prepareOutgoingSearchResponse(message); getUpnpService().getRouter().send(message); } } }
protected void sendSearchResponseRootDevices(NetworkAddress activeStreamServer) throws RouterException { log.fine("Responding to root device search with advertisement messages for all local root devices"); for (LocalDevice device : getUpnpService().getRegistry().getLocalDevices()) { if (isAdvertisementDisabled(device)) continue; OutgoingSearchResponse message = new OutgoingSearchResponseRootDevice( getInputMessage(), getDescriptorLocation(activeStreamServer, device), device ); prepareOutgoingSearchResponse(message); getUpnpService().getRouter().send(message); } }
protected void sendSearchResponseUDN(UDN udn, NetworkAddress activeStreamServer) throws RouterException { Device device = getUpnpService().getRegistry().getDevice(udn, false); if (device != null && device instanceof LocalDevice) { if (isAdvertisementDisabled((LocalDevice)device)) return; log.fine("Responding to UDN device search: " + udn); OutgoingSearchResponse message = new OutgoingSearchResponseUDN( getInputMessage(), getDescriptorLocation(activeStreamServer, (LocalDevice) device), (LocalDevice) device ); prepareOutgoingSearchResponse(message); getUpnpService().getRouter().send(message); } }
public SendingSubscribe createSendingSubscribe(RemoteGENASubscription subscription) throws ProtocolCreationException { try { List<NetworkAddress> activeStreamServers = getUpnpService().getRouter().getActiveStreamServers( subscription.getService().getDevice().getIdentity().getDiscoveredOnLocalAddress() ); return new SendingSubscribe(getUpnpService(), subscription, activeStreamServers); } catch (RouterException ex) { throw new ProtocolCreationException( "Failed to obtain local stream servers (for event callback URL creation) from router", ex ); } }
StreamResponseMessage serviceDescMsg = getUpnpService().getRouter().send(serviceDescRetrievalMsg);
response = getUpnpService().getRouter().send(getInputMessage()); } catch (RouterException ex) { onRenewalFailure();
response = getUpnpService().getRouter().send(getInputMessage()); } catch (RouterException ex) { onSubscriptionFailure();