The Device APIs Working Group is currently not progressing the approach outlined in this draft. Please treat this document with caution and do not reference it or use it as the basis for implementation. The domain covered by this document is still within the scope of the Working Group as defined in its Charter. The Working Group may resume this work or adopt an alternative approach depending on the interest of WG members and implementers.
Web Intents,[[!WEBINTENTS]], is a service discovery and light-weight RPC mechanism for web applications. The concept enables rich integration between web applications. A typical Web Intents scenario is:
A Web Intents Service is represented by a web page that declaratively marks itself as providing handling functionality for particular intents. Users register Web Intents Services by visiting web pages that contain registration markup. However, the strength of Web Intents is the ability to provide web applications with access to Services residing not only in the cloud but also in local environments.
This specification defines optional extensions to Web Intents enabled User Agents to discover and dynamically register local Web Intents Services. Note that all details of the specific low level protocols used to discover and communicate with the local services are hidden to the Client Web Applications.
The following code illustrates how a web application containing links to videos, can initiate video playback by creating and invoking a "video intent" as defined in [[!WEBINTENTS]]. This code is the same irrespective of whether the Service executing the intent action is a cloud based Service or a local Service.
// Create a new intent var intent = new Intent( "http://webintents.org/view","video/mp4",{ "src":videoCanvas.src, "img": videoCanvas.poster}); // Start intents picker navigator.startActivity(intent, // On Result function(intentData) {console.log("player.html: On Result" + intentData);}, // On Failure function(intentData) {console.log("player.html: On Failure" + intentData);});
The example below briefly describes the steps taken when a Service on a local network, e.g. UPnP or mDNS, device is discovered and selected by the user.
This specification defines conformance criteria that apply to:
Implementations that use ECMAScript to implement the APIs defined in this specification must implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], as this specification uses that specification and terminology.
This specification relies on the following specifications:
Web Intents related terms are used according to section "Terminology" in [[!WEBINTENTS]].
UPnP related terms are used according to [[!UPNP-DEVICEARCH]].
The UPnP enabled User Agent has the role of a control point according to UPnP terminology.
The Web Intents enabled UPnP device discovered by the UPnP enabled User Agent has the roles of device according to UPnP terminology.
The mDNS enabled User Agent has the role of a DNS client with capability of [[!DNS-SD]].
The Web Intents enabled mDNS device discovered by the mDNS enabled User Agent has the roles of service according to [[!MDNS]] and [[!DNS-SD]].
The Web Intents enabled UPnP device must support this section.
The Web Intents enabled UPnP device must support one UPnP service which serviceType is the urn:schemas-webintents-org:service:WebIntents:1
as a vendor specific serviceType according to [[!UPNP-DEVICEARCH]]. It is vendor dependent how the Web Intents enabled UPnP device implements the serviceType,
i.e. a device description of any deviceType could include this serviceType.
The Web Intents serviceType must have a dummy state variable, X_State
of boolean
data type to comform to [[!UPNP-DEVICEARCH]]
which requires one or more state variables in a serviceType. The X_State
state variable is not used with a value and is never evented.
The Web Intents serviceType has no standard action.
See below for the UPnP Service description document of the Web Intents serviceType.
The Web Intents enabled UPnP device must support SSDP discovery process based on standard UPnP Discovery extended with 2 additional
SSDP headers for M-SEARCH response and NOTIFY when ST/NT headers are:urn:schemas-webintents-org:service:WebIntents:1
location.webintents.org
: required. States the location to the Web Intents document in the Web Intents enabled UPnP device.
If the value of this header is a relative URL the base URL is the base URL of the LOCATION
header.
action.webintents.org
: optional. If supported, states the Web Intents
action
of the supported Web Intents Services and must
match the action
attributes of the Service registration markup in the Web Intents document. Each action string
must be surrounded by double-quotes and if more than one Web Intents action is defined
the action strings must be separated with comma.
The Web Intents enabled UPnP device must host Web Intents documents for the Web Intents Services the Web Intents enabled UPnP device supports. Web Intents documents are html pages that contain Web Intents Service registration markup according to the rules for Web Intents Service registration defined by [[!WEBINTENTS]]. They may also contain Service handler code for Services registered within the same document.
The Web Intents enabled UPnP device must host a Web Intents Service page for each Service that is
referred in Web Intents documents through href
attributes in the registration markup.
Service pages contain Service handler code and fulfills the rules for Web Intents Services as defined by [[!WEBINTENTS]].
The UPnP enabled User Agent must support discovery of Web Intents enabled UPnP devices through SSDP Discovery or through Advertisement or through both methods according to [[!UPNP-DEVICEARCH]] and according to the Web Intents serviceType and Web Intents specific SSDP headers defined in this specification, section 4.1.
The sections below describe typical steps using these methods.
The section describes the discovery process based on standard UPnP M-SEARCH multicast request.
When the navigator.startActivity method [[!WEBINTENTS]] is called, the UPnP enabled User Agent runs the following steps:
ST
header is set to: urn:schemas-webintents-org:service:WebIntents:1
urn:schemas-webintents-org:service:WebIntents:1
and the action.webintents.org
header, if present, matches the Action of the invoked intent,
the UPnP enabled User Agent attempts to retrieve the Web Intents document from the discovered Web Intents enabled UPnP device.
The value of the location.webintents.org
header is the location for the Web Intents document.
If this value is a relative URL the UPnP enabled User Agent uses the base URL of the LOCATION
header as base URL for the location of the
Web Intents document.
action.webintents.org
header is present and does not match the action
attributes of the Services registered in the retrieved Web Intents
document the UPnP enabled User Agent silently disregards the the received M-SEARCH response.
href
attribute in the registration markup for this Service according to the rules for
loading Service pages defined in [[!WEBINTENTS]].
This section describes the discovery process based on standard UPnP Advertisement with NOTIFY message.
The UPnP enabled User Agent may continuously listen to and act on advertisments according to the following steps:
NT
header equal to urn:schemas-webintents-org:service:WebIntents:1
.
action.webintents.org
header and this header matches the Action of the invoked intent.
action.webintents.org
header.
location.webintents.org
header. If this value is a relative URL the
base URL is the base URL of the LOCATION
header.
action.webintents.org
header does not match the action
attribute in the retrieved Web Intents document
the UPnP enabled User Agent silently disregards the received NOTIFY message.
href
attribute in the registration markup for this Service according to the rules for
loading Service pages defined in [[!WEBINTENTS]].
Power consumption in battery powered devices should be considered. If power consumption is severe continuously listening to SSDP advertisement in the background should not be used..
In addition to the normative statements defined in this specification a UPnP enabled User Agent that complies to this specification supports Web Intents according to [[!WEBINTENTS]] and UPnP Discovery and Description according to [[!UPNP-DEVICEARCH]].
The UPnP enabled User Agent should manage the availability of UPnP services. For example detect when contact with a Web Intents enabled UPnP device is lost through standard UPnP life cycle management and remove a previously discovered and registered Service from the Service picker. However, for battery powered devices power consumption should be considered and long lasting "keep alive" sessions" should be avoided.
This section describes how the User Agent handles Web Intents Services provided by local devices supporting mDNS and DNS-SD.
The Web Intents enabled mDNS device must support this section.
The Web Intents enabled mDNS device must support [[!DNS-SD]] with a SRV record of the webintents
service type.
A service type webintents
should be registered in [[!IANA-SRVPORT-REG]].
The TXT record for the webintents
service must have following parameters:
location
: required. States the location to the Web Intents document in the Web Intents enabled mDNS device.
The value of this header is path to be concatenated with a host of the Web Intents enabled mDNS device to determine the location. The definition of the Web Intents document is the same as for UPnP.
action
: optional. If supported, states the Web Intents
action
of the supported Web Intents Services and must
match the action
attributes of the Service registration markup in the Web Intents document. To support more than
one Web Intents action
the action strings must be separated with
comma. Commas included in action strings must be percent-encoded as
defined in [[!RFC3986]], section-2.1.
The mDNS enabled User Agent must support discovery of Web Intents enabled mDNS devices through mDNS and DNS-SD according to [[!MDNS]], [[!DNS-SD]] and according to the Web Intents specific DNS records defined in this specification, section 5.1.
When the navigator.startActivity method [[!WEBINTENTS]] is called, the mDNS enabled User Agent typically runs the following steps:
_webintents._tcp.local
in the format specified by [[!MDNS]] and [[!DNS-SD]].
This step can be omitted in case that the Web Intents enabled mDNS device attaches a TXT answer with the previous answer.
action
parameter matching the Action of the invoked intent,
send a unicast request with a SRV query of the webintens service instance.
This step can be omitted in case that the Web Intents enabled mDNS device attaches a SRV answer with the previous answer.
This step can be omitted in case that the Web Intents enabled mDNS device attaches an A and/or AAAA answer with the previous answer.
location
parameter of the TXT record.
action
parameter is present and does not match the action
attributes of the Services registered in the retrieved Web Intents
document the mDNS enabled User Agent silently disregards the the received response.
href
attribute in the registration markup for this Service according to the rules for
loading Service pages defined in [[!WEBINTENTS]].
See below for the example records for Web Intents. An mDNS enabled User Agent looking for devices supporting http://webintents.org/view Web Intents can understand that it is possible to get a Web Intents document for "LivingRoomTV" at http://192.168.1.47:3619/webintents.html.
_webintents._tcp.local. 120 IN PTR LivingRoomTV._webintents._tcp.local.
: A LivingRoomTV instance serves webintents service.
LivingRoomTV._webintents._tcp.local. 120 IN SRV 0 0 3619 TV40EX-W2000.local.
: A host "TV40EX-W2000" in the link local network offers the LivingRoomTV webintents service instance in its port 3619.
LivingRoomTV._webintents._tcp.local. 120 IN TXT location=/webintents.html action=http://webintents.org/view
: It offers http://webintents.org/view type of Web Intents. The absolute path for its Web Intents document is "/webintents.html". Note that the actual binary format of the TXT record value is concatinating key-value pairs each of which is a single byte length followed by 0-255 length key=value character string as defined in [DNS-SD].
TV40EX-W2000 120 IN A 192.168.1.47
: A host "TV40EX-W2000" is on 192.168.1.47.
The APIs / protocols for interaction between Client and Service pages are not defined by this specification. It is assumed that Web Intents based APIs and protocols will be standardized by W3C and that these will be applicable for Client and Service applications running on User Agents that comply to this specification. Different use cases will require different ways of interaction patterns between Client and Service.
Examples:
The following scenario describes how a Client page uses Web Intents to discover a remote video view service. The Service page contains the UI for controlling the video playback.
The following scenario describes how a Client page uses Web Intents to discover a remote video view service. The UI stays in the Client page, which contains the UI controls for the video playback. This means that there is a need for continuous communication between the Client page and the Service page, which is "hidden", i.e. it has no UI. The Client page creates a messaging channel and sends the messaging channel port to the Service page trhrough the intent invocation. A high level "TV control" protocol, supporting commands such as "play", "pause" and "stop, runs on top of the messaging channel.
In this example the assumption is that he Client invokes an intent to discover a Service that supports a specified protocol running on top of the message channel So the "discover" intent Action is used and Type is set to the specific protocol used to communicate with the Service.
This scenario assumes the possibility to have hidden/background Service pages or Service pages that are visible inline the Client page. Currently [[!WEBINTENTS]] does not allow this but W3C DAP Action http://www.w3.org/2009/dap/track/actions/519 should add a proposal for a hidden disposition.
Many thanks to Sony colleagues Anders Isberg, Naoyuki Sato, Tatsuya Igarashi, Anders Edenbrandt and Björn Ekberg for all support.
Many thanks to Robin Berjon for making our lives so much easier with his cool specification editing tool.