host:port information for Services

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

host:port information for Services

Jean-Claude Dufourd
I am implementing a future standard (W3C Network Service Discovery) which requires my implementation to expose to the user the full URI for description and control.
I initially thought that RemoteService.getDescriptionURI/getControlURI() were what I am looking for, but the host:port part is missing.

After some research in docs and source, I found an equivalent for LocalService, but still, no host:port.
(UPnPService.UPnPConfiguration.Namespace.getDescriptionPath...)

I failed to find host:port in Service, looked in Device, found BaseURL (always null?), PresentationURI (always null?)
I have looked at UPnPService and its children. No luck.

So I have to ask: where can I find this host:port information ? Is it at the same place for Local and Remote ?
Any hint welcome.
Thanks
Best regards
Reply | Threaded
Open this post in threaded view
|

Re: host:port information for Services

Christian Bauer
Administrator
See how SendingNotification builds the URLs for outgoing notification datagrams. Host and port is dependent on the number of active HTTP StreamServers.

Reply | Threaded
Open this post in threaded view
|

Re: host:port information for Services

Jean-Claude Dufourd
Le 22/2/13 17:37 , Christian Bauer [via Mailinglists] a écrit :
> See how SendingNotification builds the URLs for outgoing notification
> datagrams. Host and port is dependent on the number of active HTTP
> StreamServers.
>
JCD: Thank you.

For future reference, here is the complete code to create the entire
control and description URL for Local and Remote Services, as neither
case is obvious.

         if (s instanceof RemoteService) {
             ...
             ((RemoteDevice)d).normalizeURI(((RemoteService)
s).getDescriptorURI())
             ...
             ((RemoteDevice)d).normalizeURI(((RemoteService)
s).getControlURI())
             ...
         } else {
             UpnpService upnpService = ...
             Namespace ns = upnpService.getConfiguration().getNamespace();
             List<NetworkAddress> activeStreamServers =
upnpService.getRouter().getActiveStreamServers(null);
             if (activeStreamServers.size() == 0) {
                 ...
             }
             String address =
activeStreamServers.get(0).getAddress().getHostAddress();
             int port = activeStreamServers.get(0).getPort();
             stringBuilder.append("http:/");
             stringBuilder.append(address);
             stringBuilder.append(":");
             stringBuilder.append(port);
             stringBuilder.append(ns.getDescriptorPath(s));
             ...
             stringBuilder.append("http:/");
             stringBuilder.append(address);
             stringBuilder.append(":");
             stringBuilder.append(port);
             stringBuilder.append(ns.getControlPath(s));
         }

--
JC Dufourd
Directeur d'Etudes/Professor
Groupe Multimedia/Multimedia Group
Traitement du Signal et Images/Signal and Image Processing
Telecom ParisTech, 37-39 rue Dareau, 75014 Paris, France
Tel: +33145817733 - Mob: +33677843843 - Fax: +33145817144