discovery-api/Overview.src.html
author Rich Tibbett <richt@opera.com>
Mon, 03 Sep 2012 15:35:05 +0200
changeset 215 53f4bfeee4fe
child 216 5583626294f6
permissions -rw-r--r--
Revert the majority of commit 9e85394e6ede due to the deletion of files. Please always do 'hg pull' followed by 'hg update' before committing your own changes to this repo.
richt@215
     1
<!DOCTYPE html>
richt@215
     2
<html>
richt@215
     3
  <head>
richt@215
     4
    <title>Networked Service Discovery and Messaging</title>
richt@215
     5
    <meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
richt@215
     6
    <script type="text/javascript" class='remove'>
richt@215
     7
      var respecConfig = {
richt@215
     8
          specStatus:   "ED",
richt@215
     9
          //publishDate:  "2012-08-22",
richt@215
    10
          shortName:    "discovery-api",
richt@215
    11
          edDraftURI:   "http://w3c-test.org/dap/discovery-api/",
richt@215
    12
          previousMaturity: "WD",
richt@215
    13
          previousPublishDate: "2012-08-07",
richt@215
    14
          editors: [
richt@215
    15
            {
richt@215
    16
              name:       "Rich Tibbett",
richt@215
    17
              //url:        "http://richt.me/",
richt@215
    18
              company:    "Opera Software ASA",
richt@215
    19
              companyURL: "http://opera.com/"
richt@215
    20
            },
richt@215
    21
            {
richt@215
    22
              name:       "Clarke Stevens",
richt@215
    23
              //url:      "",
richt@215
    24
              company:    "CableLabs",
richt@215
    25
              companyURL: "http://cablelabs.com/"
richt@215
    26
            }
richt@215
    27
          ],
richt@215
    28
          noIDLIn:      true,
richt@215
    29
          wg:           "Device APIs and Policy Working Group",
richt@215
    30
          wgURI:        "http://www.w3.org/2009/dap/",
richt@215
    31
          wgPublicList: "public-device-apis",
richt@215
    32
          wgPatentURI:  "http://www.w3.org/2004/01/pp-impl/43696/status"
richt@215
    33
      };
richt@215
    34
    </script>
richt@215
    35
richt@215
    36
    <script src='http://www.w3.org/Tools/respec/respec-w3c-common' type="text/javascript" class='remove' async></script>
richt@215
    37
    <style type="text/css">
richt@215
    38
      /* Custom CSS optimizations (Richard Tibbett) */
richt@215
    39
richt@215
    40
      /* Add better spacing to sections */
richt@215
    41
      section, .section { margin-bottom: 2em; }
richt@215
    42
richt@215
    43
      /* Reduce note & issue render size */
richt@215
    44
      .note, .issue { font-size:0.8em; }
richt@215
    45
richt@215
    46
      /* Add addition spacing to <ol> and <ul> for rule definition */
richt@215
    47
      ol.rule li, ul.rule li { padding:0.6em; }
richt@215
    48
richt@215
    49
      pre.widl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
richt@215
    50
      pre.widl :link, pre.widl :visited { color: #000; background: transparent; }
richt@215
    51
      pre.widl:before { content: "IDL"; font: bold small sans-serif; padding: 0.5em; background: white; position: absolute; top: 0; margin: -1px 0 0 -4em; width: 1.5em; border: thin solid; border-radius: 0 0 0 0.5em }
richt@215
    52
richt@215
    53
      div.example { border: solid thin red; background: #F7DFE5; color: black; padding: 0.5em 1em; position: relative; margin: 1em 0 1em 4.6em; width: auto; }
richt@215
    54
      div.example:before { content: "EXAMPLE"; font: bold small sans-serif; padding: 0.5em; background: red; color: white; position: absolute; top: 0; margin: -1px 0 0 -7.6em; width: 5em; border: thin solid red; border-radius: 0 0 0 0.5em }
richt@215
    55
richt@215
    56
      dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
richt@215
    57
      hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
richt@215
    58
      dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
richt@215
    59
      dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
richt@215
    60
      dl.domintro dd p { margin: 0.5em 0; }
richt@215
    61
      dl.domintro code {font-size: inherit; font-style: italic; }
richt@215
    62
      dl.domintro:before { display: table; margin: -1em -0.5em 0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: red; border: solid 2px; background: white; padding: 0 0.25em; }
richt@215
    63
    </style>
richt@215
    64
  </head>
richt@215
    65
richt@215
    66
  <body>
richt@215
    67
    <section id='abstract'>
richt@215
    68
      <p>
richt@215
    69
        This specification defines a mechanism for an HTML document to discover and subsequently communicate with <abbr title="Hypertext Transfer Protocol">HTTP</abbr>-based services
richt@215
    70
        advertised via common discovery protocols within a user's network.
richt@215
    71
      </p>
richt@215
    72
    </section>
richt@215
    73
richt@215
    74
    <section id='sotd'>
richt@215
    75
      <p>
richt@215
    76
        This document represents the early consensus of the group on the scope and features of the proposed
richt@215
    77
        API.
richt@215
    78
      </p>
richt@215
    79
    </section>
richt@215
    80
richt@215
    81
    <section class="informative">
richt@215
    82
      <h3>Introduction</h3>
richt@215
    83
richt@215
    84
      <p>To enable Web pages to connect and communicate with Local-networked Services provided over HTTP, this specification introduces the
richt@215
    85
      <a href="#navigatornetworkservice"><code>NavigatorNetworkService</code></a> interface.</p>
richt@215
    86
richt@215
    87
      <p>
richt@215
    88
         Using this <abbr title="Application Programming Interface">API</abbr> consists of requesting a well-known service type, known by developers and advertised by Local-networked Devices. User authorization, where the user connects the web page to one or more discovered services,
richt@215
    89
         is expected before the web page is able to interact with any Local-networked Services.
richt@215
    90
      </p>
richt@215
    91
richt@215
    92
      <p>
richt@215
    93
         A web page creates a request to obtain connectivity to services running in the network by specifying a well-known discovery service type that it wishes to interact with.
richt@215
    94
      </p>
richt@215
    95
richt@215
    96
      <p>
richt@215
    97
         The user agent, having captured all advertised services on the network from the Service Discovery mechanisms included in this recommendation, attempts to match
richt@215
    98
      the requested service type to a discovered service according to the processing described herein.
richt@215
    99
      </p>
richt@215
   100
richt@215
   101
      <p>
richt@215
   102
          If a service connectivity request is successful then the Web page is provided with the necessary information to communicate with the authorized Local-networked Service.
richt@215
   103
          If the request fails then the Web page will receive an error callback containing an error code describing the cause of Local-networked Service connectivity failure.
richt@215
   104
      </p>
richt@215
   105
richt@215
   106
      <p>
richt@215
   107
         Once connected to a Local-networked Service the Web page can send requests and receive responses to the Local-networked Service via the messaging format and appropriate channel inferred from the service type
richt@215
   108
         authorized via the provided API.
richt@215
   109
         The Web page, once connected, can also receive service-pushed events, in the messaging format supported by the Local-networked Device, if such event subscription functionality is provided by the
richt@215
   110
         connected Local-networked Service.
richt@215
   111
      </p>
richt@215
   112
richt@215
   113
      <div class="example">
richt@215
   114
       <p>Example of requesting a DNS-SD advertised service:</p>
richt@215
   115
       <hr />
richt@215
   116
       <pre class="highlight">function showServices( services ) {
richt@215
   117
  // Show a list of all the services provided to the web page
richt@215
   118
  for(var i = 0, l = services.length; i < l; i++) console.log( services[i].name );
richt@215
   119
}
richt@215
   120
richt@215
   121
navigator.getNetworkServices('zeroconf:_boxee-jsonrpc._tcp', showServices);</pre>
richt@215
   122
      </div>
richt@215
   123
richt@215
   124
      <div class="example">
richt@215
   125
        <p>Example of requesting a UPnP advertised service, also handling error conditions:</p>
richt@215
   126
        <hr />
richt@215
   127
        <pre class="highlight">function showServices( services ) {
richt@215
   128
  // Show a list of all the services provided to the web page
richt@215
   129
  for(var i = 0, l = services.length; i < l; i++) console.log( services[i].name );
richt@215
   130
}
richt@215
   131
richt@215
   132
function error( e ) {
richt@215
   133
  console.log( "Error occurred: " + e.code );
richt@215
   134
}
richt@215
   135
richt@215
   136
navigator.getNetworkServices('upnp:urn:schemas-upnp-org:service:ContentDirectory:1', showServices, error);</pre>
richt@215
   137
      </div>
richt@215
   138
richt@215
   139
      <div class="example">
richt@215
   140
        <p>Example of requesting either a DNS-SD or UPnP advertised service:</p>
richt@215
   141
        <hr />
richt@215
   142
        <pre class="highlight">function showServices( services ) {
richt@215
   143
  // Show a list of all the services provided to the web page (+ service type)
richt@215
   144
  for(var i = 0, l = services.length; i < l; i++)
richt@215
   145
     console.log( services[i].name + '(' + services[i].type + ')' );
richt@215
   146
}
richt@215
   147
richt@215
   148
navigator.getNetworkServices([
richt@215
   149
  'zeroconf:_boxee-jsonrpc._tcp',
richt@215
   150
  'upnp:urn:schemas-upnp-org:service:ContentDirectory:1'
richt@215
   151
], showServices);</pre>
richt@215
   152
      </div>
richt@215
   153
richt@215
   154
      <p>For more detailed examples see the <a href="#examples">Examples</a> section.
richt@215
   155
    </section>
richt@215
   156
richt@215
   157
    <section
richt@215
   158
     id='conformance'>
richt@215
   159
richt@215
   160
     <p>Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the
richt@215
   161
     meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.</p>
richt@215
   162
richt@215
   163
     <p>
richt@215
   164
      Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
richt@215
   165
     </p>
richt@215
   166
richt@215
   167
     <p>
richt@215
   168
      Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in
richt@215
   169
      this specification are intended to be easy to follow, and not intended to be performant.)
richt@215
   170
     </p>
richt@215
   171
richt@215
   172
     <p>
richt@215
   173
      The only conformance class defined by this specification is a <dfn>user agent</dfn>.
richt@215
   174
     </p>
richt@215
   175
richt@215
   176
     <p>
richt@215
   177
      User agents may impose implementation-specific limits on otherwise unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of memory, or to work
richt@215
   178
      around platform-specific limitations.
richt@215
   179
     </p>
richt@215
   180
richt@215
   181
     <p>
richt@215
   182
      When support for a feature is disabled (e.g. as an emergency measure to mitigate a security problem, or to aid in development, or for performance reasons), user agents must act as if
richt@215
   183
      they had no support for the feature whatsoever, and as if the feature was not mentioned in this specification. For example, if a particular feature is accessed via an attribute in a Web
richt@215
   184
      IDL interface, the attribute itself would be omitted from the objects that implement that interface - leaving the attribute on the object but making it return null or throw an exception
richt@215
   185
      is insufficient.
richt@215
   186
     </p>
richt@215
   187
richt@215
   188
      <section>
richt@215
   189
         <h3>Dependencies</h3>
richt@215
   190
richt@215
   191
         This specification relies on several other underlying specifications.
richt@215
   192
richt@215
   193
         <dl>
richt@215
   194
            <dt>HTML</dt>
richt@215
   195
            <dd>Many fundamental concepts from HTML are used by this specification. [[!HTML5]]</dd>
richt@215
   196
            <dt>WebIDL</dt>
richt@215
   197
            <dd>The IDL blocks in this specification use the semantics of the WebIDL specification. [[!WEBIDL]]</dd>
richt@215
   198
         </dl>
richt@215
   199
      </section>
richt@215
   200
    </section>
richt@215
   201
richt@215
   202
    <section>
richt@215
   203
      <h3>Terminology</h3>
richt@215
   204
richt@215
   205
      <p>
richt@215
   206
         The construction "a <code>Foo</code> object", where <code>Foo</code> is actually an interface, is sometimes used instead of the more accurate "an object implementing the interface <code>Foo</code>".
richt@215
   207
      </p>
richt@215
   208
richt@215
   209
      <p>
richt@215
   210
         The term DOM is used to refer to the API set made available to scripts in Web applications, and does not necessarily imply the existence of an actual <code>Document</code> object or of any
richt@215
   211
         other <code>Node</code> objects as defined in the DOM Core specifications. [[!DOM4]]
richt@215
   212
      </p>
richt@215
   213
richt@215
   214
      <p>
richt@215
   215
         An IDL attribute is said to be <em>getting</em> when its value is being retrieved (e.g. by author script), and is said to be <em>setting</em> when a new value is assigned to it.
richt@215
   216
      </p>
richt@215
   217
richt@215
   218
      <p>
richt@215
   219
        A <dfn>valid service type</dfn> is a string that begins with <code>upnp:</code> or <code>zeroconf:</code> followed by one or more characters in the ranges U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E, U+0030 to U+0039, U+0041 to U+005A, U+005E to U+007E.
richt@215
   220
      </p>
richt@215
   221
richt@215
   222
      <p>
richt@215
   223
        A <a>valid service type</a> provided in the <code>type</code> attribute of the <code>getNetworkServices()</code> method will be matched against the services currently contained in the <a>list of available service records</a> according to the algorithms defined in this specification.
richt@215
   224
      </p>
richt@215
   225
    </section>
richt@215
   226
richt@215
   227
    <section>
richt@215
   228
     <h2>Requesting networked services</h2>
richt@215
   229
richt@215
   230
richt@215
   231
<pre class="widl">[Supplemental, NoInterfaceObject]
richt@215
   232
interface <dfn id="navigatornetworkservice">NavigatorNetworkService</dfn> {
richt@215
   233
  // Obtain a Local-networked Service
richt@215
   234
  void <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>( in any type,
richt@215
   235
                           in <a href="#navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</a> successCallback,
richt@215
   236
                           in optional <a href="#navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</a> errorCallback );
richt@215
   237
};
richt@215
   238
<a class="externalDFN" href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">Navigator</a> implements <a href="#navigatornetworkservice">NavigatorNetworkService</a>;
richt@215
   239
richt@215
   240
[Callback=FunctionOnly, NoInterfaceObject]
richt@215
   241
interface <dfn id="navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</dfn> {
richt@215
   242
  void handleEvent( in <a href="#networkservices">NetworkServices</a> services );
richt@215
   243
};
richt@215
   244
richt@215
   245
[NoInterfaceObject]
richt@215
   246
interface <dfn id="navigatornetworkserviceerror">NavigatorNetworkServiceError</dfn> {
richt@215
   247
  const unsigned short <a href="#dom-navigatornetworkserviceerror-permission_denied">PERMISSION_DENIED_ERR</a> = 1;
richt@215
   248
  const unsigned short <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix">UNKNOWN_TYPE_PREFIX_ERR</a> = 2;
richt@215
   249
  readonly attribute unsigned short <a href="#dom-navigatornetworkserviceerror-code">code</a>;
richt@215
   250
};
richt@215
   251
richt@215
   252
[Callback=FunctionOnly, NoInterfaceObject]
richt@215
   253
interface <dfn id="navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</dfn> {
richt@215
   254
  void handleEvent( in <a href="#navigatornetworkserviceerror">NavigatorNetworkServiceError</a> error );
richt@215
   255
};
richt@215
   256
</pre>
richt@215
   257
richt@215
   258
  <section>
richt@215
   259
   <h2>Methods</h2>
richt@215
   260
richt@215
   261
      <dl class="domintro">
richt@215
   262
        <dt>
richt@215
   263
          <var title="">window</var>
richt@215
   264
           .
richt@215
   265
          <code title="dom-navigator">
richt@215
   266
            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">navigator</a>
richt@215
   267
          </code>
richt@215
   268
           .
richt@215
   269
          <code title="dom-navigator-getNetworkServices">
richt@215
   270
            <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>
richt@215
   271
          </code>
richt@215
   272
          (
richt@215
   273
          <var title="">type</var>
richt@215
   274
          ,
richt@215
   275
          <var title="">successCallback</var>
richt@215
   276
           [,
richt@215
   277
          <var title="">errorCallback</var>
richt@215
   278
           ] )
richt@215
   279
        </dt>
richt@215
   280
        <dd>
richt@215
   281
          <p>Prompts the user to select one or more discovered network services that have advertised support for the requested service type.</p>
richt@215
   282
          <p>
richt@215
   283
            The
richt@215
   284
            <var title="">type</var>
richt@215
   285
             argument contains one or more <a>valid service type</a> tokens that the web page would like to interact with.
richt@215
   286
          </p>
richt@215
   287
          <p>
richt@215
   288
            If the user accepts, the
richt@215
   289
            <var title="">successCallback</var>
richt@215
   290
             is
richt@215
   291
          invoked, with one or more
richt@215
   292
            <code>
richt@215
   293
              <a href="#networkservice"><code>NetworkService</code></a>
richt@215
   294
            </code>
richt@215
   295
             objects as
richt@215
   296
          its argument.
richt@215
   297
          </p>
richt@215
   298
          <p>
richt@215
   299
            If the user declines, the
richt@215
   300
            <var title="">errorCallback</var>
richt@215
   301
             (if
richt@215
   302
          any) is invoked.
richt@215
   303
          </p>
richt@215
   304
        </dd>
richt@215
   305
      </dl>
richt@215
   306
richt@215
   307
       <div>
richt@215
   308
          <p>
richt@215
   309
            When the <dfn id="dom-navigator-getnetworkservices" title="dom-navigator-getnetworkservices"><code>getNetworkServices(type, successCallback[, errorCallback])</code></dfn> method is called, the <a>user agent</a> MUST run the following steps:
richt@215
   310
          </p>
richt@215
   311
richt@215
   312
          <ol class="rule">
richt@215
   313
richt@215
   314
            <li>
richt@215
   315
              Let <var>requested control types</var> be initially set to an empty array.
richt@215
   316
            </li>
richt@215
   317
richt@215
   318
            <li>
richt@215
   319
               If <var>type</var> is an array consisting of one or more <a>valid service type</a> tokens, then let <var>requested control types</var> by the value of <var>type</var>, removing any non-<a>valid service type</a> tokens from the resulting array.
richt@215
   320
            </li>
richt@215
   321
richt@215
   322
            <li>
richt@215
   323
               If <var>type</var> is a string consisting of one <a>valid service type</a> token, then let <var>requested control types</var> be an array containing one item with a value of <var>type</var>.
richt@215
   324
            </li>
richt@215
   325
richt@215
   326
            <li>
richt@215
   327
               If <var>requested control types</var> is an array that contains at least one or more <a title="valid service type">valid service type</a> tokens then continue to the step labeled <em>process</em> below. Otherwise, the <a>user agent</a> MUST <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
richt@215
   328
                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 2
richt@215
   329
                  (<a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a>) as its argument,
richt@215
   330
                   abort any remaining steps and return.
richt@215
   331
            </li>
richt@215
   332
richt@215
   333
            <li>
richt@215
   334
               <em>Process</em>: Let <var>services found</var> be an empty array.
richt@215
   335
            </li>
richt@215
   336
richt@215
   337
            <li>
richt@215
   338
               For each <var>available service</var> in the <a>list of available service records</a> run the following steps:
richt@215
   339
               <ol class="rule">
richt@215
   340
                  <li>
richt@215
   341
                    For each <var>requested control type</var> in <var>requested control types</var>: If <var>available service</var>'s <code>type</code> attribute equals the <var>requested control type</var> then let <var>matched service</var> equal the value of <var>available service</var> and continue at the step labeled <var>attach</var> below.
richt@215
   342
                  </li>
richt@215
   343
                  <li>
richt@215
   344
                     Continue at the next <var>available service</var>.
richt@215
   345
                  </li>
richt@215
   346
                  <li>
richt@215
   347
                     <em>Attach</em>: If <var>matched service</var> is not empty then run the following steps:
richt@215
   348
richt@215
   349
                     <ol class="rule">
richt@215
   350
                        <li>
richt@215
   351
                           Let <var>new service object</var> be a new <a href="#networkservice"><code>NetworkService</code></a> object, mapping the parameters of
richt@215
   352
                     <var>matched service</var> to this new object where possible.
richt@215
   353
                        </li>
richt@215
   354
                        <li>
richt@215
   355
                           Append <var>new service object</var> to the <var>services found</var> array.
richt@215
   356
                        </li>
richt@215
   357
                     </ol>
richt@215
   358
                  </li>
richt@215
   359
               </ol>
richt@215
   360
            </li>
richt@215
   361
richt@215
   362
            <li>
richt@215
   363
               If <var>services found</var> is an empty array, then the <a>user agent</a> MUST <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
richt@215
   364
                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
richt@215
   365
                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
richt@215
   366
            </li>
richt@215
   367
richt@215
   368
            <li>
richt@215
   369
               Return, and run the remaining steps asynchronously.
richt@215
   370
            </li>
richt@215
   371
richt@215
   372
            <li>
richt@215
   373
               Optionally, e.g. based on a previously-established user preference, for security reasons, or due to platform limitations, the <a>user agent</a> MAY <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
richt@215
   374
                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
richt@215
   375
                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
richt@215
   376
            </li>
richt@215
   377
richt@215
   378
            <li>
richt@215
   379
                  The <a>user agent</a> MUST prompt the user in a user-agent-specific manner for permission to provide the
richt@215
   380
                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
richt@215
   381
                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> with an array of
richt@215
   382
                  <a href="#networkservice"><code>NetworkService</code></a> objects representing the user-authorized subset of <var>services found</var>.
richt@215
   383
richt@215
   384
               <p>
richt@215
   385
                  If the user grants permission to access one or more networked services then the <a>user agent</a> SHOULD include an
richt@215
   386
                  "ongoing local-network communication" indicator.
richt@215
   387
               </p>
richt@215
   388
richt@215
   389
               <p>If the user denies permission, then the <a>user agent</a> MUST <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
richt@215
   390
                <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
richt@215
   391
                (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
richt@215
   392
              </p>
richt@215
   393
richt@215
   394
              <p>
richt@215
   395
                If the user never responds, this algorithm stalls on this step.
richt@215
   396
              </p>
richt@215
   397
richt@215
   398
            </li>
richt@215
   399
richt@215
   400
            <li>
richt@215
   401
               Let <var>services</var> be the array of one or more <a href="#networkservice"><code>NetworkService</code></a> objects for which the user granted permission.
richt@215
   402
            </li>
richt@215
   403
richt@215
   404
            <li>
richt@215
   405
               For each Object <var>service</var> in <var>services</var>, run the following substeps:
richt@215
   406
richt@215
   407
               <ol class="rule">
richt@215
   408
                  <li>
richt@215
   409
                     Add the <var>service</var>'s <code>url</code> parameter to the <a>entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
richt@215
   410
                  </li>
richt@215
   411
                  <li>
richt@215
   412
                    If <var>service</var>'s <code>type</code> parameter begins with the DOMString &quot;<code>upnp:</code>&quot; and the <var>service</var>'s <code>eventsUrl</code> parameter is not empty then <a>setup a UPnP Events Subscription</a> for <var>service</var>.
richt@215
   413
                  </li>
richt@215
   414
               </ol>
richt@215
   415
            </li>
richt@215
   416
richt@215
   417
            <li>
richt@215
   418
               Let <var>services manager</var> be a new <a href="#networkservices"><code>NetworkServices</code></a> object.
richt@215
   419
            </li>
richt@215
   420
richt@215
   421
            <li>
richt@215
   422
               Set <var>services manager</var>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute to the length of <var>services</var>.
richt@215
   423
            </li>
richt@215
   424
richt@215
   425
            <li>
richt@215
   426
              Store the set of <var>services</var> as <dfn id="current_authorized_services">current authorized services</dfn> internally against the newly created <var>services manager</var> object.
richt@215
   427
            </li>
richt@215
   428
richt@215
   429
            <li>
richt@215
   430
               The <a>user agent</a> MUST <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>successCallback</var> with
richt@215
   431
               <var>services manager</var> as its argument.
richt@215
   432
            </li>
richt@215
   433
richt@215
   434
          </ol>
richt@215
   435
richt@215
   436
          <p>
richt@215
   437
            The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#task-source" class="externalDFN">task source</a> for these
richt@215
   438
            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#concept-task" class="externalDFN">tasks</a> is the
richt@215
   439
            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#user-interaction-task-source" class="externalDFN">user interaction task source</a>.
richt@215
   440
          </p>
richt@215
   441
richt@215
   442
          <p>
richt@215
   443
            When a <a href="#networkservice"><code>NetworkService</code></a> object is provided to a Web page, the <a>user agent</a> MUST add the <code>url</code> property
richt@215
   444
             to the <dfn>entry script origin's URL whitelist</dfn>. This list enables the
richt@215
   445
            Web page to override and initiate cross-site resource requests towards these URLs, and any sub-resources of these URLs, within the current
richt@215
   446
            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
richt@215
   447
            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> via various existing mechanisms (e.g. Web Sockets, Server-Sent Events,
richt@215
   448
            Web Messaging, XMLHttpRequest).
richt@215
   449
         </p>
richt@215
   450
richt@215
   451
         <p>
richt@215
   452
            If the user navigates away from the current browsing context, the <a>user agent</a> MUST remove all previously whitelisted urls from the <a>entry script origin's URL whitelist</a>.
richt@215
   453
            There is no persistence to network service selections provided to a web page. It is not possible to access a previously white-listed networked service without the necessary user authorization in all of the following cases:
richt@215
   454
            <ul>
richt@215
   455
              <li>If the current script is reloaded at any point in the same or different window.</li>
richt@215
   456
              <li>if the current script reinvokes the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method at any point in its execution.</li>
richt@215
   457
              <li>If the user navigates forward or back in their history to reload the current page.</li>
richt@215
   458
              <li>If a script is running in a different origin.</li>
richt@215
   459
            </ul>
richt@215
   460
         </p>
richt@215
   461
richt@215
   462
      </div>
richt@215
   463
      </section>
richt@215
   464
richt@215
   465
      <section>
richt@215
   466
         <h3>Error Handling</h3>
richt@215
   467
richt@215
   468
      <dl class="domintro">
richt@215
   469
        <dt>
richt@215
   470
          <var title="">error</var>
richt@215
   471
           .
richt@215
   472
          <code title="dom-NavigatorNetworkServiceError-code">
richt@215
   473
            <a href="#dom-navigatornetworkserviceerror-code">code</a>
richt@215
   474
          </code>
richt@215
   475
        </dt>
richt@215
   476
        <dd>
richt@215
   477
          <p>
richt@215
   478
            Returns the current error's error code. At the current time, this may be <code>1</code> or <code>2</code>, for which the
richt@215
   479
            corresponding error constants
richt@215
   480
            <a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a> and
richt@215
   481
            <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a> are defined.
richt@215
   482
          </p>
richt@215
   483
        </dd>
richt@215
   484
      </dl>
richt@215
   485
richt@215
   486
         <p>
richt@215
   487
            The <dfn id="dom-navigatornetworkserviceerror-code" title="dom-navigatornetworkserviceerror-code"><code>code</code></dfn> attribute of a
richt@215
   488
            <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object MUST return the code for the error, which will be one of the following:
richt@215
   489
         </p>
richt@215
   490
richt@215
   491
         <dl>
richt@215
   492
            <dt>
richt@215
   493
               <dfn id="dom-navigatornetworkserviceerror-permission_denied" title="dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></dfn> (numeric value 1)
richt@215
   494
            </dt>
richt@215
   495
            <dd>
richt@215
   496
               The user or user agent denied the page permission to access any services.
richt@215
   497
            </dd>
richt@215
   498
            <dt>
richt@215
   499
               <dfn id="dom-navigatornetworkserviceerror-unknown_type_prefix" title="dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></dfn> (numeric value 2)
richt@215
   500
            </dt>
richt@215
   501
            <dd>
richt@215
   502
               No <a>valid service type</a> tokens were provided in the method invocation.
richt@215
   503
            </dd>
richt@215
   504
         </dl>
richt@215
   505
richt@215
   506
      </section>
richt@215
   507
richt@215
   508
      </section>
richt@215
   509
      <section>
richt@215
   510
      <h2>Obtaining networked services</h2>
richt@215
   511
richt@215
   512
      <p>
richt@215
   513
         The <a href="#networkservices"><code>NetworkServices</code></a> interface is the top-level response object from a call to <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> and provides access to a set of user-authorized <a href="#networkservice"><code>NetworkService</code></a> objects for the given request.
richt@215
   514
      </p>
richt@215
   515
richt@215
   516
<pre class="widl">
richt@215
   517
[NoInterfaceObject]
richt@215
   518
interface <dfn id="networkservices">NetworkServices</dfn> {
richt@215
   519
  readonly attribute unsigned long    <a href="#dom-networkservices-length">length</a>;
richt@215
   520
  getter <a href="#networkservice">NetworkService</a> (unsigned long index);
richt@215
   521
  <a href="#networkservice">NetworkService</a>? <a href="#dom-networkservices-getservicebyid">getServiceById</a>(DOMString id);
richt@215
   522
richt@215
   523
  readonly attribute unsigned long    <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>;
richt@215
   524
richt@215
   525
  // event handler attributes
richt@215
   526
           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservices-onserviceavailable">onserviceavailable</a>;
richt@215
   527
           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservices-onserviceunavailable">onserviceunavailable</a>;
richt@215
   528
richt@215
   529
};
richt@215
   530
richt@215
   531
<a href="#networkservices">NetworkServices</a> implements <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget" class="externalDFN">EventTarget</a>;
richt@215
   532
</pre>
richt@215
   533
richt@215
   534
      <section>
richt@215
   535
      <h2>Attributes</h2>
richt@215
   536
richt@215
   537
        <dl class="domintro">
richt@215
   538
          <dt>
richt@215
   539
            <code title="dom-networkservices-length">
richt@215
   540
              <a href="#dom-networkservices-length">length</a>
richt@215
   541
            </code>
richt@215
   542
          </dt>
richt@215
   543
          <dd>
richt@215
   544
            <p>
richt@215
   545
              Returns the current number of services in the respective object's <a>current authorized services</a>.
richt@215
   546
            </p>
richt@215
   547
          </dd>
richt@215
   548
          <dt>
richt@215
   549
            <code title="dom-networkservices-servicesavailable">
richt@215
   550
              <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>
richt@215
   551
            </code>
richt@215
   552
          </dt>
richt@215
   553
          <dd>
richt@215
   554
            <p>
richt@215
   555
              Returns the current number of services matching one of the app-requested <a>valid service type</a> tokens that are actively available within the user's current network.
richt@215
   556
            </p>
richt@215
   557
          </dd>
richt@215
   558
        </dl>
richt@215
   559
richt@215
   560
        <div>
richt@215
   561
           <p>
richt@215
   562
              The <dfn id="dom-networkservices-length"><code>length</code></dfn> attribute MUST return the number of services represented in the object's corresponding <a>current authorized services</a> list at the time of getting.
richt@215
   563
           </p>
richt@215
   564
richt@215
   565
           <p>
richt@215
   566
              The <dfn id="dom-networkservices-servicesavailable"><code>servicesAvailable</code></dfn> attribute MUST return the number of services available in the
richt@215
   567
              user's network that match the <a>valid service type</a> that was initially used to create the current <a href="#networkservices"><code>NetworkServices</code></a> object.
richt@215
   568
           </p>
richt@215
   569
richt@215
   570
           <p>
richt@215
   571
             When a previously unknown instance of a networked service matching one of the requested <a href="#dfn-valid-service-type">valid service types</a> becomes available on the user's current network, the <a>user agent</a> MUST increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute by <code>1</code> and then
richt@215
   572
             <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
richt@215
   573
             to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does
richt@215
   574
             not bubble, is not cancellable, and has no default action, at the current <a href="#networkservices"><code>NetworkServices</code></a>
richt@215
   575
             object.
richt@215
   576
           </p>
richt@215
   577
richt@215
   578
           <p>
richt@215
   579
             When a previously known instance of a networked service matching one of the requested <a href="#dfn-valid-service-type">valid service types</a> becomes unavailable on the user's current network, the <a>user agent</a> MUST decrement the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute by <code>1</code> and then
richt@215
   580
             <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
richt@215
   581
              to dispatch a newly created event with the name <code>serviceunavailable</code> that uses the <code>Event</code> interface, which does
richt@215
   582
              not bubble, is not cancellable, and has no default action, at the current <a href="#networkservices"><code>NetworkServices</code></a>
richt@215
   583
              object.
richt@215
   584
           </p>
richt@215
   585
        </div>
richt@215
   586
richt@215
   587
      </section>
richt@215
   588
richt@215
   589
      <section>
richt@215
   590
      <h2>Methods</h2>
richt@215
   591
        <dl class="domintro">
richt@215
   592
        <dt>
richt@215
   593
          <code title="networkservices-getter">
richt@215
   594
            <a href="#networkservices">services</a>
richt@215
   595
          </code>
richt@215
   596
          [
richt@215
   597
          <var title="">index</var>
richt@215
   598
          ]
richt@215
   599
        </dt>
richt@215
   600
        <dd>
richt@215
   601
          <p>
richt@215
   602
            Returns the specified <a href="#networkservice"><code>NetworkService</code></a> object.
richt@215
   603
          </p>
richt@215
   604
        </dd>
richt@215
   605
        <dt>
richt@215
   606
          <code title="networkservices-getter">
richt@215
   607
            <a href="#networkservices">services</a>
richt@215
   608
          </code>
richt@215
   609
          .
richt@215
   610
          <code title="dom-networkservices-getservicebyid">
richt@215
   611
            <a href="#dom-networkservices-getservicebyid">getServiceById</a>
richt@215
   612
          </code>
richt@215
   613
          (
richt@215
   614
          <var title="">id</var>
richt@215
   615
          )
richt@215
   616
        </dt>
richt@215
   617
        <dd>
richt@215
   618
          <p>
richt@215
   619
            Returns the <a href="#networkservice"><code>NetworkService</code></a> object with the given identifier, or null if no
richt@215
   620
            service has that identifier.
richt@215
   621
          </p>
richt@215
   622
        </dd>
richt@215
   623
      </dl>
richt@215
   624
richt@215
   625
      <p>
richt@215
   626
        A <a href="#networkservices"><code>NetworkServices</code></a> object represents the current list of zero or more <a>current authorized services</a>, of which zero or more can be available at a time. Each item in <a>current authorized services</a> is represented by a <a href="#networkservice"><code>NetworkService</code></a> object. The list of <a>current authorized services</a> is <span>immutable</span> meaning that it cannot be modified for the lifetime of a <a href="#networkservices"><code>NetworkServices</code></a> object.
richt@215
   627
      </p>
richt@215
   628
richt@215
   629
      <p class="note">
richt@215
   630
        Each service in a <a href="#networkservices"><code>NetworkServices</code></a> object thus has an index; the first has the index 0, and each subsequent service is numbered one higher than the previous one. If the <a>user agent</a> dynamically adds or removes network services for any reason, then the indices of the services in <a>current authorized services</a> will change dynamically. If the set of network services changes entirely, then all the previous services will be removed from <a>current authorized services</a> and replaced with new services.
richt@215
   631
      </p>
richt@215
   632
richt@215
   633
      <p>
richt@215
   634
        The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#supported-property-indices" class="externalDFN">supported property indices</a> of <a href="#networkservices"><code>NetworkServices</code></a> objects at any instant are the numbers from zero to the number of items in <a>current authorized services</a> represented by the respective object minus one, if any services are represented in <a>current authorized services</a>. If a <a href="#networkservices"><code>NetworkServices</code></a> object represents no <a>current authorized services</a>, it has no <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#supported-property-indices" class="externalDFN">supported property indices</a>.
richt@215
   635
      </p>
richt@215
   636
richt@215
   637
      <p>
richt@215
   638
        To <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#determine-the-value-of-an-indexed-property" class="externalDFN">determine the value of an indexed property</a> for a given index <var>index</var> in a <a href="#networkservices"><code>NetworkServices</code></a> object's <a>current authorized services</a>, the user agent MUST return the <a href="#networkservice"><code>NetworkService</code></a> object that represents the <var>index</var>th service in <a>current authorized services</a>.
richt@215
   639
      </p>
richt@215
   640
richt@215
   641
      <p>
richt@215
   642
        The <dfn id="dom-networkservices-getservicebyid"><code>getServiceById(id)</code></dfn> method MUST return the first <a href="#networkservice"><code>NetworkService</code></a> object in <a>current authorized services</a> represented by the respective object whose <a href="#dom-networkservice-id"><code>id</code></a> attribute is equal to the value of the <var>id</var> argument.
richt@215
   643
        When no services in <a>current authorized services</a> match the given argument, the method MUST return null.
richt@215
   644
      </p>
richt@215
   645
richt@215
   646
      <p>
richt@215
   647
         Services available within the local network can connect and disconnect at different times during the execution of a web page. A <a>user agent</a> can
richt@215
   648
         inform a web page when the state of networked services matching the requested <a>valid service type</a> change. Web pages can use this information to enable in-page experiences for communicating the state of networked services
richt@215
   649
         with the ability to change the particular service or set of services the page is connected to by re-invoking the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method.
richt@215
   650
      </p>
richt@215
   651
richt@215
   652
      </section>
richt@215
   653
richt@215
   654
      <section>
richt@215
   655
      <h2>Events</h2>
richt@215
   656
richt@215
   657
      <p>
richt@215
   658
         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the <a href="#networkservices"><code>NetworkServices</code></a> interface:
richt@215
   659
       </p>
richt@215
   660
richt@215
   661
       <table border="1">
richt@215
   662
        <thead>
richt@215
   663
          <tr>
richt@215
   664
            <th>
richt@215
   665
              <span title="event handlers">Event handler</span>
richt@215
   666
            </th>
richt@215
   667
            <th>
richt@215
   668
              <span>Event handler event type</span>
richt@215
   669
            </th>
richt@215
   670
          </tr>
richt@215
   671
        </thead>
richt@215
   672
        <tbody>
richt@215
   673
          <tr>
richt@215
   674
            <td>
richt@215
   675
              <dfn id="dom-networkservices-onserviceavailable" title="dom-NetworkServices-onserviceavailable">
richt@215
   676
                <code>onserviceavailable</code>
richt@215
   677
              </dfn>
richt@215
   678
            </td>
richt@215
   679
            <td>
richt@215
   680
              <code title="event-serviceavailable">serviceavailable</code>
richt@215
   681
            </td>
richt@215
   682
          </tr>
richt@215
   683
          <tr>
richt@215
   684
            <td>
richt@215
   685
              <dfn id="dom-networkservices-onserviceunavailable" title="dom-NetworkServices-onserviceunavailable">
richt@215
   686
                <code>onserviceunavailable</code>
richt@215
   687
              </dfn>
richt@215
   688
            </td>
richt@215
   689
            <td>
richt@215
   690
              <code title="event-serviceunavailable">serviceunavailable</code>
richt@215
   691
            </td>
richt@215
   692
          </tr>
richt@215
   693
        </tbody>
richt@215
   694
      </table>
richt@215
   695
richt@215
   696
      <p>
richt@215
   697
         Events with an event type of <code>serviceavailable</code> or <code>serviceunavailable</code> defined in this specification are simple <code>Event</code> objects.
richt@215
   698
      </p>
richt@215
   699
richt@215
   700
      </section>
richt@215
   701
richt@215
   702
    </section>
richt@215
   703
    <section>
richt@215
   704
    <h2>Communicating with a networked service</h3>
richt@215
   705
richt@215
   706
<p>
richt@215
   707
   The <a href="#networkservice"><code>NetworkService</code></a> interface is used to provide a set of connection information for an HTTP service endpoint and if available, service events, running on a networked device.
richt@215
   708
</p>
richt@215
   709
richt@215
   710
<pre class="widl">
richt@215
   711
[NoInterfaceObject]
richt@215
   712
interface <dfn id="networkservice">NetworkService</dfn> {
richt@215
   713
  readonly attribute DOMString        <a href="#dom-networkservice-id">id</a>;
richt@215
   714
  readonly attribute DOMString        <a href="#dom-networkservice-name">name</a>;
richt@215
   715
  readonly attribute DOMString        <a href="#dom-networkservice-type">type</a>;
richt@215
   716
  readonly attribute DOMString        <a href="#dom-networkservice-url">url</a>;
richt@215
   717
  readonly attribute DOMString        <a href="#dom-networkservice-config">config</a>;
richt@215
   718
richt@215
   719
  readonly attribute boolean          <a href="#dom-networkservice-online">online</a>;
richt@215
   720
richt@215
   721
  // event handler attributes
richt@215
   722
           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onserviceonline">onserviceonline</a>;
richt@215
   723
           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onserviceoffline">onserviceoffline</a>;
richt@215
   724
richt@215
   725
           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onnotify">onnotify</a>;
richt@215
   726
};
richt@215
   727
richt@215
   728
<a href="#networkservice">NetworkService</a> implements <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget" class="externalDFN">EventTarget</a>;
richt@215
   729
</pre>
richt@215
   730
richt@215
   731
<section>
richt@215
   732
  <h2>Attributes</h2>
richt@215
   733
richt@215
   734
      <dl class="domintro">
richt@215
   735
        <dt>
richt@215
   736
          <var title="">service</var>
richt@215
   737
           .
richt@215
   738
          <code title="dom-networkservice-id">
richt@215
   739
            <a href="#dom-networkservice-id">id</a>
richt@215
   740
          </code>
richt@215
   741
        </dt>
richt@215
   742
        <dd>
richt@215
   743
          <p>
richt@215
   744
            A unique identifier for the given user-selected service instance.
richt@215
   745
          </p>
richt@215
   746
        </dd>
richt@215
   747
        <dt>
richt@215
   748
          <var title="">service</var>
richt@215
   749
           .
richt@215
   750
          <code title="dom-networkservice-name">
richt@215
   751
            <a href="#dom-networkservice-name">name</a>
richt@215
   752
          </code>
richt@215
   753
        </dt>
richt@215
   754
        <dd>
richt@215
   755
          <p>
richt@215
   756
            The name of the user-selected service.
richt@215
   757
          </p>
richt@215
   758
        </dd>
richt@215
   759
        <dt>
richt@215
   760
          <var title="">service</var>
richt@215
   761
           .
richt@215
   762
          <code title="dom-networkservice-type">
richt@215
   763
            <a href="#dom-networkservice-type">type</a>
richt@215
   764
          </code>
richt@215
   765
        </dt>
richt@215
   766
        <dd>
richt@215
   767
          <p>
richt@215
   768
            The <a>valid service type</a> token value of the user-selected service.
richt@215
   769
          </p>
richt@215
   770
        </dd>
richt@215
   771
        <dt>
richt@215
   772
          <var title="">service</var>
richt@215
   773
           .
richt@215
   774
          <code title="dom-networkservice-url">
richt@215
   775
            <a href="#dom-networkservice-url">url</a>
richt@215
   776
          </code>
richt@215
   777
        </dt>
richt@215
   778
        <dd>
richt@215
   779
          <p>
richt@215
   780
            The control URL endpoint (including any required port information) of the user-selected control service that has been added to the <a>entry script origin's URL whitelist</a>.
richt@215
   781
          </p>
richt@215
   782
        </dd>
richt@215
   783
        <dt>
richt@215
   784
          <var title="">service</var>
richt@215
   785
           .
richt@215
   786
          <code title="dom-networkservice-config">
richt@215
   787
            <a href="#dom-networkservice-config">config</a>
richt@215
   788
          </code>
richt@215
   789
        </dt>
richt@215
   790
        <dd>
richt@215
   791
          <p>
richt@215
   792
            The configuration information associated with the service depending on the requested service type.
richt@215
   793
          </p>
richt@215
   794
        </dd>
richt@215
   795
      </dl>
richt@215
   796
richt@215
   797
          <p>
richt@215
   798
            The <dfn id="dom-networkservice-id"><code>id</code></dfn> attribute is a unique identifier for the service. The same service provided at different times or on different objects MUST have the same <a href="#dom-networkservice-id"><code>id</code></a> value.
richt@215
   799
         </p>
richt@215
   800
richt@215
   801
         <p>
richt@215
   802
            The <dfn id="dom-networkservice-name"><code>name</code></dfn> attribute represents a human-readable title for the service.
richt@215
   803
         </p>
richt@215
   804
richt@215
   805
         <p>
richt@215
   806
             The <dfn id="dom-networkservice-type"><code>type</code></dfn> attribute reflects the value of the <a>valid service type</a> of the service.
richt@215
   807
          </p>
richt@215
   808
richt@215
   809
         <p>
richt@215
   810
            The <dfn id="dom-networkservice-url"><code>url</code></dfn> attribute is an <a href="http://www.w3.org/TR/html5/urls.html#absolute-url" class="externalDFN">absolute URL</a> pointing to the root HTTP
richt@215
   811
            endpoint for the service that has been added to the <a>entry script origin's URL whitelist</a>. Web pages can subsequently use this value for implicit cross-document messaging via various existing mechanisms (e.g. Web Sockets, Server-Sent Events, Web Messaging, XMLHttpRequest).
richt@215
   812
         </p>
richt@215
   813
richt@215
   814
         <p>
richt@215
   815
            The <dfn id="dom-networkservice-config"><code>config</code></dfn> attribute provides the raw configuration information extracted from the given network service.
richt@215
   816
         </p>
richt@215
   817
richt@215
   818
      </section>
richt@215
   819
richt@215
   820
      <section>
richt@215
   821
         <h3>States</h3>
richt@215
   822
richt@215
   823
      <dl class="domintro">
richt@215
   824
        <dt>
richt@215
   825
          <var title="">service</var>
richt@215
   826
           .
richt@215
   827
          <code title="dom-networkservice-online">
richt@215
   828
            <a href="#dom-networkservice-online">online</a>
richt@215
   829
          </code>
richt@215
   830
        </dt>
richt@215
   831
        <dd>
richt@215
   832
          <p>
richt@215
   833
            Returns <code>true</code> if the service is reporting that it is accessible on the local network or <code>false</code> if the service is reporting that it is no longer accessible (temporarily or permanently) on the local network.
richt@215
   834
          </p>
richt@215
   835
        </dd>
richt@215
   836
      </dl>
richt@215
   837
richt@215
   838
      <p>
richt@215
   839
        The <dfn id="dom-networkservice-online"><code>online</code></dfn> attribute indicates whether the service is reporting itself as being
richt@215
   840
        either <var>online</var>, and therefore accessible on the local network, in which case this attribute will return <code>true</code> or, <var>offline</var>, and therefore not accessible on the local network, either temporarily or permanently, in which case this attribute will return <code>false</code>. This attribute MUST default to <code>true</code>.
richt@215
   841
      </p>
richt@215
   842
richt@215
   843
      </section>
richt@215
   844
richt@215
   845
      <section>
richt@215
   846
         <h3>Events</h3>
richt@215
   847
richt@215
   848
      <p>
richt@215
   849
         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the
richt@215
   850
         <a href="#networkservice"><code>NetworkService</code></a> interface:
richt@215
   851
       </p>
richt@215
   852
richt@215
   853
       <table border="1">
richt@215
   854
        <thead>
richt@215
   855
          <tr>
richt@215
   856
            <th>
richt@215
   857
              <span title="event handlers">Event handler</span>
richt@215
   858
            </th>
richt@215
   859
            <th>
richt@215
   860
              <span>Event handler event type</span>
richt@215
   861
            </th>
richt@215
   862
          </tr>
richt@215
   863
        </thead>
richt@215
   864
        <tbody>
richt@215
   865
          <tr>
richt@215
   866
            <td>
richt@215
   867
              <dfn id="dom-networkservice-onnotify" title="dom-NetworkService-onnotify">
richt@215
   868
                <code>onnotify</code>
richt@215
   869
              </dfn>
richt@215
   870
            </td>
richt@215
   871
            <td>
richt@215
   872
              <code title="event-notify">notify</code>
richt@215
   873
            </td>
richt@215
   874
          </tr>
richt@215
   875
          <tr>
richt@215
   876
            <td>
richt@215
   877
              <dfn id="dom-networkservice-onserviceonline" title="dom-NetworkService-onserviceonline">
richt@215
   878
                <code>onserviceonline</code>
richt@215
   879
              </dfn>
richt@215
   880
            </td>
richt@215
   881
            <td>
richt@215
   882
              <code title="event-onserviceonline">serviceonline</code>
richt@215
   883
            </td>
richt@215
   884
          </tr>
richt@215
   885
          <tr>
richt@215
   886
            <td>
richt@215
   887
              <dfn id="dom-networkservice-onserviceoffline" title="dom-NetworkService-onserviceoffline">
richt@215
   888
                <code>onserviceoffline</code>
richt@215
   889
              </dfn>
richt@215
   890
            </td>
richt@215
   891
            <td>
richt@215
   892
              <code title="event-onserviceoffline">serviceoffline</code>
richt@215
   893
            </td>
richt@215
   894
          </tr>
richt@215
   895
        </tbody>
richt@215
   896
      </table>
richt@215
   897
richt@215
   898
      <p>
richt@215
   899
         Events with an event type of <code>notify</code>, <code>serviceonline</code> or <code>serviceoffline</code> defined in this specification are simple <code>Event</code> objects.
richt@215
   900
      </p>
richt@215
   901
richt@215
   902
      </section>
richt@215
   903
   </section>
richt@215
   904
richt@215
   905
      <section>
richt@215
   906
            <h2>Service Discovery</h2>
richt@215
   907
richt@215
   908
      <p>
richt@215
   909
         A <a>user agent</a> conforming to this specification MAY implement <acronym title="Simple Service Discovery Protocol">SSDP</acronym> [[!UPNP-DEVICEARCH11]] and Zeroconf [[!DNS-SD]] + [[!MDNS]] service discovery mechanisms
richt@215
   910
         to enable Web pages to request and connect with HTTP services running on networked devices, discovered via either mechanism, through this API. When a <a>user agent</a> implements either of these service discovery mechanisms, then it MUST conform to the corresponding algorithms provided in this section of the specification.
richt@215
   911
      </p>
richt@215
   912
      <p>
richt@215
   913
         This section presents how the results of these two service discovery
richt@215
   914
         mechanisms will be matched to requested service types and how their properties will be applied to any resulting <a href="#networkservice"><code>NetworkService</code></a> objects.
richt@215
   915
      </p>
richt@215
   916
richt@215
   917
      <p>
richt@215
   918
         It is expected that user agents will perform these service discovery mechansisms asynchronously and periodically update the <a>list of networked devices</a> as required. The timing of any
richt@215
   919
         service discovery mechanisms is an implementation detail left to the discretion of the implementer (e.g. once on user agent start-up, every X seconds during user agent execution or on
richt@215
   920
         invocation of this API from a Web page).
richt@215
   921
      </p>
richt@215
   922
richt@215
   923
      <p>
richt@215
   924
         The <dfn>list of available service records</dfn> is a single dynamic internal lookup table within user agents that is used to track the current services available in the network at any given time.
richt@215
   925
         At any point during the running of either of the two service discovery mechanisms then existing entries within this table can be updated, entries can be added and entries can be removed as the status of networked
richt@215
   926
         services changes. Each record contained within this table contains the attributes: <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code> and <code>config</code>.
richt@215
   927
      </p>
richt@215
   928
richt@215
   929
            <section>
richt@215
   930
         <h4>Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr>)</h4>
richt@215
   931
richt@215
   932
         <p>
richt@215
   933
            For each DNS response received from a user-agent-initiated Multicast DNS Browse for <abbr title="DNS Pointer Record">PTR</abbr> records with the name <code>_services._dns-sd._udp</code> on the resolved recommended automatic browsing
richt@215
   934
   domain [[!MDNS]], the <a>user agent</a> MUST run the following steps:
richt@215
   935
         </p>
richt@215
   936
richt@215
   937
         <ol class="rule">
richt@215
   938
richt@215
   939
            <li>Let <var>service mDNS responses</var> be an array of PTR records received by issuing a Multicast DNS Browse for PTR records with the name of the current discovered service type.</li>
richt@215
   940
richt@215
   941
            <li>For each Object <var>service mDNS response</var> in <var>service mDNS responses</var>, run the following steps:
richt@215
   942
               <ol>
richt@215
   943
richt@215
   944
                  <li>
richt@215
   945
                     Let <var>network service record</var> be an Object consisting of the following empty properties: <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code>, <code>config</code>.
richt@215
   946
                  </li>
richt@215
   947
richt@215
   948
                  <li>
richt@215
   949
                     Set <var>network service record</var>'s <code>id</code> property to the value of the full PTR Service Instance Name [[!MDNS]].
richt@215
   950
                  </li>
richt@215
   951
richt@215
   952
                  <li>
richt@215
   953
                     Set <var>network service record</var>'s <code>name</code> property to the value of the PTR Service Instance Name's <var>Instance</var> component [[!MDNS]].
richt@215
   954
                  </li>
richt@215
   955
richt@215
   956
                  <li>
richt@215
   957
                     Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string <code>zeroconf:</code> followed by the value of the PTR Service Instance Name's <var>Service</var> component [[!MDNS]].
richt@215
   958
                  </li>
richt@215
   959
richt@215
   960
                  <li>
richt@215
   961
                     Set <var>network service record</var>'s <code>url</code> property to the resolvable Service URL obtained from performing an DNS-SD Lookup [[!DNS-SD]] of the current service from the PTR record provided [[!MDNS]].
richt@215
   962
                  </li>
richt@215
   963
richt@215
   964
                  <li>
richt@215
   965
                     Set <var>network service record</var>'s <code>config</code> property to the string value of the contents of the first DNS-SD TXT record associated with the <var>service mDNS response</var> as defined in [[!DNS-SD]].
richt@215
   966
                  </li>
richt@215
   967
richt@215
   968
                  <li>
richt@215
   969
                     For each Object <var>existing service record</var> in the current <a>list of available service records</a>, run the following sub-steps:
richt@215
   970
                     <ol class="rule">
richt@215
   971
richt@215
   972
                       <li>
richt@215
   973
                        If the <var>existing service record</var>'s <code>id</code> property matches the value of the <var>network service record</var>'s <code>id</code>, then set the
richt@215
   974
                        value of <var>existing service record</var> in the current <a>list of available service records</a>  to the value of the
richt@215
   975
                        <var>network service record</var> and skip the next step.
richt@215
   976
                       </li>
richt@215
   977
                     </ol>
richt@215
   978
                  </li>
richt@215
   979
richt@215
   980
                  <li>
richt@215
   981
                     Add <var>network service record</var> to the <a>list of available service records</a>.
richt@215
   982
                  </li>
richt@215
   983
richt@215
   984
                  <li>
richt@215
   985
                     For each non-garbage collected <a href="#networkservice"><code>NetworkService</code></a> object run the following steps:
richt@215
   986
richt@215
   987
                     <ol class="rule">
richt@215
   988
                        <li>
richt@215
   989
                           If the <a href="#networkservice"><code>NetworkService</code></a> object's <code>type</code> attribute does not equal the
richt@215
   990
                           current <a>network service record</a>'s <code>type</code> property then continue at the next available active
richt@215
   991
                           <a href="#networkservice"><code>NetworkService</code></a> object.
richt@215
   992
                        </li>
richt@215
   993
                        <li>
richt@215
   994
                           Increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <a href="#networkservices"><code>NetworkServices</code></a> object by <code>1</code>.
richt@215
   995
                        </li>
richt@215
   996
                        <li>
richt@215
   997
                          <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
richt@215
   998
                           to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
richt@215
   999
                            <a href="#networkservices"><code>NetworkServices</code></a> object.
richt@215
  1000
                        </li>
richt@215
  1001
                        <li>
richt@215
  1002
                          <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
richt@215
  1003
                           to dispatch a newly created event with the name <code>serviceonline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
richt@215
  1004
                           <a href="#networkservice"><code>NetworkService</code></a> object.
richt@215
  1005
                        </li>
richt@215
  1006
                     </ol>
richt@215
  1007
                  </li>
richt@215
  1008
            </ol>
richt@215
  1009
           </li>
richt@215
  1010
         </ol>
richt@215
  1011
richt@215
  1012
      </section>
richt@215
  1013
richt@215
  1014
      <section>
richt@215
  1015
         <h5>Universal Plug-and-Play (<abbr title="Universal Plug-and-Play">UPnP</abbr>)</h5>
richt@215
  1016
richt@215
  1017
         <p>
richt@215
  1018
            For each SSDP Presence Announcement [[!UPNP-DEVICEARCH11]] - a HTTP NOTIFY request - received from a user-agent-initiated SSDP Discovery Request [[!UPNP-DEVICEARCH11]], the <a>user agent</a> MUST run the following steps:
richt@215
  1019
         </p>
richt@215
  1020
richt@215
  1021
         <ol class="rule">
richt@215
  1022
            <li>
richt@215
  1023
               Let <var>ssdp device</var> be an Object with a property for each HTTP header received in the received SSDP Presence Announcement, with each key being the name of a HTTP header and its
richt@215
  1024
               value being that HTTP header's accompanying value.
richt@215
  1025
            </li>
richt@215
  1026
richt@215
  1027
            <li>
richt@215
  1028
               If <var>ssdp device</var> does not contain at least one <var>NTS</var>, <var>USN</var> and <var>Location</var> parameter, then the <a>user agent</a> MUST abort these steps.
richt@215
  1029
            </li>
richt@215
  1030
richt@215
  1031
            <li>
richt@215
  1032
               If the first occurrence of <var>NTS</var> has a value other than <code>ssdp:alive</code>, then continue to the step labeled <var>update service monitor</var> below.
richt@215
  1033
            </li>
richt@215
  1034
richt@215
  1035
            <li>
richt@215
  1036
               Let <var>root device descriptor file</var> contain the contents of the file located at the URL provided in the first occurrence of <var>Location</var> obtained according to the rules
richt@215
  1037
               defined in the section 'Retrieving a description using HTTP' [[!UPNP-DEVICEARCH11]].
richt@215
  1038
            </li>
richt@215
  1039
richt@215
  1040
            <li>
richt@215
  1041
               If <var>root device descriptor file</var> is empty, then the <a>user agent</a> MUST abort these steps.
richt@215
  1042
            </li>
richt@215
  1043
richt@215
  1044
            <li>
richt@215
  1045
               Let <var>advertised services</var> be a <a>list of all advertised services</a> obtained from the <var>root device descriptor file</var> containing all sub-nodes of the <code>serviceList</code> node as described in
richt@215
  1046
               the section 'Device Description' [[!UPNP-DEVICEARCH11]].
richt@215
  1047
            </li>
richt@215
  1048
richt@215
  1049
            <li>
richt@215
  1050
               For each Object <var>advertised service</var> in <var>advertised services</var> run the following steps:
richt@215
  1051
               <ol class="rule">
richt@215
  1052
richt@215
  1053
                  <li>
richt@215
  1054
                     Let <var>network service record</var> be an Object consisting of the following empty properties: <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code>, <code>eventsUrl</code>, <code>config</code>.
richt@215
  1055
                  </li>
richt@215
  1056
richt@215
  1057
                  <li>
richt@215
  1058
                     Set <var>network service record</var>'s <code>id</code> property to the string value of the first occurrence of <var>ssdp device</var>'s <var>USN</var> parameter.
richt@215
  1059
                  </li>
richt@215
  1060
richt@215
  1061
                  <li>
richt@215
  1062
                     Set <var>network service record</var>'s <code>name</code> property to the string value of the first occurrence of the <var>service</var>'s <code>serviceId</code> property.
richt@215
  1063
                  </li>
richt@215
  1064
richt@215
  1065
                  <li>
richt@215
  1066
                     Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string <code>upnp:</code> followed by the string value of the first occurrence of the <var>service</var>'s <code>serviceType</code> property.
richt@215
  1067
                  </li>
richt@215
  1068
richt@215
  1069
                  <li>
richt@215
  1070
                     Set <var>network service record</var>'s <code>url</code> property to the string value of the first occurrence of the <var>service</var>'s <code>controlURL</code> property.
richt@215
  1071
                  </li>
richt@215
  1072
richt@215
  1073
                  <li>
richt@215
  1074
                     Set <var>network service record</var>'s <code>config</code> property to the string value of the first occurrence of the <var>device</var> property.
richt@215
  1075
                  </li>
richt@215
  1076
richt@215
  1077
                  <li>
richt@215
  1078
                     If <var>service</var>'s <code>eventSubURL</code> property is empty, then continue to the step labeled <em>register</em> below.
richt@215
  1079
                  </li>
richt@215
  1080
richt@215
  1081
                  <li>
richt@215
  1082
                     Set <var>network service record</var>'s <code>eventsUrl</code> property to the string value of the first occurrence of the <var>service</var>'s <code>eventSubURL</code> property.
richt@215
  1083
                  </li>
richt@215
  1084
richt@215
  1085
                  <li>
richt@215
  1086
                     <em>Register</em>: For each Object <var>existing service record</var> in the current <a>list of available service records</a>, run the following sub-steps:
richt@215
  1087
                     <ol class="rule">
richt@215
  1088
richt@215
  1089
                       <li>
richt@215
  1090
                        If the <var>existing service record</var>'s <var>id</var> property matches the value of the first occurrence of <var>USN</var> and the
richt@215
  1091
                        <var>existing service record</var>'s <code>type</code> property matches the value of <var>network service record</var>'s <code>type</code>, then set the
richt@215
  1092
                        value of <var>existing service record</var> in the current <a>list of available service records</a>  to the value of the
richt@215
  1093
                        <var>network service record</var> and skip the next step.
richt@215
  1094
                       </li>
richt@215
  1095
                     </ol>
richt@215
  1096
                  </li>
richt@215
  1097
richt@215
  1098
                  <li>
richt@215
  1099
                     Add <var>network service record</var> to the <a>list of available service records</a>.
richt@215
  1100
                  </li>
richt@215
  1101
richt@215
  1102
               </ol>
richt@215
  1103
            </li>
richt@215
  1104
            <li>
richt@215
  1105
               <em>Update Service Monitor</em>: For each non-garbage collected <a href="#networkservice"><code>NetworkService</code></a> object run the following steps:
richt@215
  1106
richt@215
  1107
               <ol class="rule">
richt@215
  1108
                  <li>
richt@215
  1109
                     If this <a href="#networkservice"><code>NetworkService</code></a> object's <code>type</code> attribute does not equal the
richt@215
  1110
                     current <a>network service record</a>'s <code>type</code> property then continue at the next available active
richt@215
  1111
                     <a href="#networkservice"><code>NetworkService</code></a> object.
richt@215
  1112
                  </li>
richt@215
  1113
                  <li>
richt@215
  1114
                     If the <var>announcement type</var> equals <code>ssdp:alive</code> then increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <a href="#networkservices"><code>NetworkServices</code></a>
richt@215
  1115
                     object by <code>1</code> and then <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
richt@215
  1116
                      to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
richt@215
  1117
                      <a href="#networkservice"><code>NetworkServices</code></a> object. Otherwise, decrement the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <a href="#networkservices"><code>NetworkServices</code></a>
richt@215
  1118
                     object by <code>1</code> and then  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
richt@215
  1119
                       to dispatch a newly created event with the name <code>serviceunavailable</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
richt@215
  1120
                       <a href="#networkservice"><code>NetworkServices</code></a> object.
richt@215
  1121
                  </li>
richt@215
  1122
                  <li>
richt@215
  1123
                     If the <var>announcement type</var> equals <code>ssdp:alive</code> then <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
richt@215
  1124
                      to dispatch a newly created event with the name <code>serviceonline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
richt@215
  1125
                      <a href="#networkservice"><code>NetworkService</code></a> object. Otherwise, <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
richt@215
  1126
                       to dispatch a newly created event with the name <code>serviceoffline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
richt@215
  1127
                       <a href="#networkservice"><code>NetworkService</code></a> object.
richt@215
  1128
                  </li>
richt@215
  1129
               </ol>
richt@215
  1130
            </li>
richt@215
  1131
         </ol>
richt@215
  1132
richt@215
  1133
         <p>
richt@215
  1134
            A <dfn>user-agent generated callback url</dfn> is a Local-network accessible URL endpoint that a <a>user agent</a> must generate and maintain for receiving HTTP NOTIFY requests from UPnP Event sources.
richt@215
  1135
         </p>
richt@215
  1136
richt@215
  1137
         <p>When the <a>user agent</a> is to <dfn>setup a UPnP Events Subscription</dfn>, it is to run the following steps with the current <var>network service record</var> object:</p>
richt@215
  1138
richt@215
  1139
         <ol class="rule">
richt@215
  1140
            <li>
richt@215
  1141
               If <var>network service record</var>'s <code>eventsUrl</code> property is empty then the <a>user agent</a> MUST abort these steps.
richt@215
  1142
            </li>
richt@215
  1143
richt@215
  1144
            <li>
richt@215
  1145
               Let <var>callback URL</var> be the value of creating a new <a>user-agent generated callback url</a>.
richt@215
  1146
            </li>
richt@215
  1147
richt@215
  1148
            <li>
richt@215
  1149
               Send a HTTP SUBSCRIBE request with a <em>NT</em> header with a string value of <code>upnp:event</code>, a <em>TIMEOUT</em> header with an integer value ofÆ’
richt@215
  1150
               <code>86400</code> and a <em>CALLBACK</em> header
richt@215
  1151
               with a string value of <var>callback URL</var> towards the <var>network service record</var>'s <code>eventsUrl</code> property.
richt@215
  1152
            </li>
richt@215
  1153
richt@215
  1154
            <li>
richt@215
  1155
               If a non-200 OK response is received from the HTTP SUBSCRIBE request then the <a>user agent</a> MUST abort these steps.
richt@215
  1156
            </li>
richt@215
  1157
richt@215
  1158
            <li>
richt@215
  1159
               On receiving a valid 200 OK response, run the following steps:
richt@215
  1160
richt@215
  1161
               <ol class="rule">
richt@215
  1162
                  <li>
richt@215
  1163
                     Let <var>callback ID</var> equal the string value of the first included <em>SID</em> header, if it exists.
richt@215
  1164
                  </li>
richt@215
  1165
                  <li>
richt@215
  1166
                     Let <var>timeout date</var> equal the sum of the current UTC date value plus the integer value of the first included <em>TIMEOUT</em> header, if it exists.
richt@215
  1167
                  </li>
richt@215
  1168
                  <li>
richt@215
  1169
                     Run the following steps aynchronously and continue to the step labeled <em>listen</em> below.
richt@215
  1170
                  </li>
richt@215
  1171
                  <li>
richt@215
  1172
                     <em>Refresh Subscription</em>: Run the following steps at a set interval (X) within the <a>user agent</a>:
richt@215
  1173
richt@215
  1174
                     <ol class="rule">
richt@215
  1175
                        <li>
richt@215
  1176
                           Let <var>current date</var> equal the current UTC date.
richt@215
  1177
                        </li>
richt@215
  1178
                        <li>
richt@215
  1179
                           If <var>current date</var> is less than the <var>timeout date</var> then continue to the step labeled <em>refresh subscription</em> above.
richt@215
  1180
                        </li>
richt@215
  1181
                        <li>
richt@215
  1182
                           Send a HTTP SUBSCRIBE request with a <em>SID</em> header with the string value of <var>callback ID</var> and a <em>TIMEOUT</em> header
richt@215
  1183
                           with an integer value of <code>86400</code> towards the <var>network service record</var>'s <code>eventsUrl</code> property.
richt@215
  1184
                        </li>
richt@215
  1185
                        <li>
richt@215
  1186
                           On receiving a valid 200 OK, update <var>callback ID</var> with the string value of the first included <em>SID</em> header, if it exists. All other HTTP
richt@215
  1187
                           responses should cause the <a>user agent</a> to continue from the step labeled <em>refresh subscription</em> above.
richt@215
  1188
                        </li>
richt@215
  1189
                     </ol>
richt@215
  1190
richt@215
  1191
                  </li>
richt@215
  1192
richt@215
  1193
                  <li>
richt@215
  1194
                     <em>Listen</em>: For each HTTP NOTIFY request received at the <var>callback URL</var> the <a>user agent</a> is to run the following steps:
richt@215
  1195
richt@215
  1196
                     <ol class="rule">
richt@215
  1197
                        <li>
richt@215
  1198
                           Let <var>content clone</var> be the result of obtaining the message body of the HTTP NOTIFY request. If <var>content clone</var> is empty, then the <a>user agent</a> MUST abort these steps.
richt@215
  1199
                        </li>
richt@215
  1200
                        <li>
richt@215
  1201
                          Let <var>notification event</var> be a new simple event that uses the <code>Event</code> interface with the name <code>notify</code>,
richt@215
  1202
                           which does not bubble, is not cancellable, and has no default action.
richt@215
  1203
                        </li>
richt@215
  1204
                        <li>
richt@215
  1205
                           Let the <code>data</code> attribute of <var>notification event</var> have the DOMString value of <var>content clone</var>.
richt@215
  1206
                        </li>
richt@215
  1207
                        <li>
richt@215
  1208
                           <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a> to
richt@215
  1209
                            dispatch <var>notification event</var> at the current <a><code>NetworkService</code></a> object.
richt@215
  1210
                        </li>
richt@215
  1211
                     </ol>
richt@215
  1212
                  </li>
richt@215
  1213
richt@215
  1214
               </ol>
richt@215
  1215
richt@215
  1216
            </li>
richt@215
  1217
         </ol>
richt@215
  1218
richt@215
  1219
         </section>
richt@215
  1220
richt@215
  1221
         <section>
richt@215
  1222
            <h3>Network Topology Monitoring</h3>
richt@215
  1223
richt@215
  1224
                  <div>
richt@215
  1225
                     <p>
richt@215
  1226
                        When the <a>user agent</a> detects that the user has dropped from their connected network, then it MUST run the following steps:
richt@215
  1227
                     </p>
richt@215
  1228
richt@215
  1229
                     <ol class="rule">
richt@215
  1230
                        <li>
richt@215
  1231
                           Flush all entries from the <a>list of available service records</a>.
richt@215
  1232
                        </li>
richt@215
  1233
                        <li>
richt@215
  1234
                           For each <a href="#networkservice"><code>NetworkService</code></a> object currently active in the <a>user agent</a> perform the following steps:
richt@215
  1235
richt@215
  1236
                           <ol class="rule">
richt@215
  1237
                              <li>
richt@215
  1238
                                 Set the <a href="#dom-networkservice-online"><code>online</code></a> attribute to <code>false</code>.
richt@215
  1239
                              </li>
richt@215
  1240
                              <li>
richt@215
  1241
                                 <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
richt@215
  1242
                                                      to dispatch a newly created event with the name <code>serviceoffline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
richt@215
  1243
                                                      <a href="#networkservice"><code>NetworkService</code></a> object.
richt@215
  1244
                           </ol>
richt@215
  1245
                        </li>
richt@215
  1246
                        <li>
richt@215
  1247
                          For each <a href="#networkservices"><code>NetworkServices</code></a> object currently active in the <a>user agent</a> perform the following steps:
richt@215
  1248
richt@215
  1249
                          <ol class="rule">
richt@215
  1250
                            <li>
richt@215
  1251
                              Let <var>number of available services</var> equal the value of <a href="#networkservices"><code>NetworkServices</code></a>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute.
richt@215
  1252
                            </li>
richt@215
  1253
                            <li>
richt@215
  1254
                              Set the <a href="#networkservices"><code>NetworkServices</code></a>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute to zero (<code>0</code>).
richt@215
  1255
                            </li>
richt@215
  1256
                            <li>
richt@215
  1257
                              For each <var>available service</var> in <var>number of available services</var> the <a>user agent</a> MUST fire a new simple event with the name <code>serviceunavailable</code> that has no default action, does not bubble and is not cancellable, at the current <a href="#networkservices"><code>NetworkServices</code></a> object.
richt@215
  1258
                            </li>
richt@215
  1259
                          </ol>
richt@215
  1260
                        </li>
richt@215
  1261
richt@215
  1262
                     </ol>
richt@215
  1263
richt@215
  1264
                     <p>
richt@215
  1265
                        When the <a>user agent</a> detects that the user has connected to a new network, then it SHOULD run the following steps:
richt@215
  1266
                     </p>
richt@215
  1267
richt@215
  1268
                     <ol class="rule">
richt@215
  1269
                        <li>
richt@215
  1270
                           Re-issue an mDNS search and SSDP discovery search using all of the <a>valid service type</a> tokens initially provided to all active <a href="#networkservices"><code>NetworkServices</code></a> objects and handle all discovery responses according to the processing defined in <a href="#service-discovery">Section 7: Service Discovery</a>.
richt@215
  1271
                        </li>
richt@215
  1272
                     </ol>
richt@215
  1273
                  </div>
richt@215
  1274
         </section>
richt@215
  1275
      </section>
richt@215
  1276
richt@215
  1277
   <section>
richt@215
  1278
      <h3>Garbage collection</h3>
richt@215
  1279
richt@215
  1280
      <p>
richt@215
  1281
         A <a><code>NetworkService</code></a> object containing a <code>url</code> parameter currently in the <a>entry script origin's URL whitelist</a> MUST NOT be garbage collected.
richt@215
  1282
      </p>
richt@215
  1283
richt@215
  1284
      <p>
richt@215
  1285
         Only when the user navigates away from the current browsing context can <a><code>NetworkService</code></a> objects be garbage-collected and records in the <a>entry script origin's URL whitelist</a> be removed.
richt@215
  1286
      </p>
richt@215
  1287
richt@215
  1288
   </section>
richt@215
  1289
richt@215
  1290
richt@215
  1291
    <section>
richt@215
  1292
      <h3>Use Cases and Requirements</h3>
richt@215
  1293
richt@215
  1294
      <p>This section covers what the requirements are for this API, as well as illustrates some use cases.</p>
richt@215
  1295
richt@215
  1296
      <ul class="rule">
richt@215
  1297
         <li>
richt@215
  1298
            Once a user has given permission, user agents should provide the ability for Web pages to communicate directly with a Local-networked Service.
richt@215
  1299
            <ul class="rule">
richt@215
  1300
               <li>
richt@215
  1301
                  Example: A web-based TV remote control. A Web page wants to control the current user's TV, changing the programming shown or increasing/decreasing/muting the
richt@215
  1302
                  volume of the Local-networked Device. The Web page requests a service type that is known to be implemented by television sets to which it has the
richt@215
  1303
                  application logic to communicate. Local devices providing the request service types are discovered and presented to the user for authorization. The user selects one
richt@215
  1304
                  or more of the discovered television sets to be accessible to the current Web page and then clicks 'Share'. The Web page can now communicate directly with
richt@215
  1305
                  the user-authorized Local-networked services.
richt@215
  1306
               </li>
richt@215
  1307
            </ul>
richt@215
  1308
         </li>
richt@215
  1309
richt@215
  1310
         <li>
richt@215
  1311
           Web pages should be able to communicate with Local-networked Services using the messaging channel supported by those Devices.
richt@215
  1312
           <ul class="rule">
richt@215
  1313
            <li>
richt@215
  1314
               Example: A Web page advertises that it is capable of controlling multiple Home Media Servers. The user can select their Home Media Server type from a drop-down list, at which point the
richt@215
  1315
               Web page sends a request to the user agent to connect with the associated service type of the Home Media Server. The Media Server selected implements a Web Socket channel for
richt@215
  1316
               bi-directional service communication and so the Web page opens a web socket to the requested Media Server and can communicate as required via that appropriate channel.
richt@215
  1317
            </li>
richt@215
  1318
           </ul>
richt@215
  1319
         </li>
richt@215
  1320
richt@215
  1321
         <li>
richt@215
  1322
           Web pages should be able to communicate with Local-networked Services using the messaging format supported by those Devices.
richt@215
  1323
           <ul class="rule">
richt@215
  1324
            <li>
richt@215
  1325
               Example: A Web page advertises that it is capable of interacting with and controlling multiple types of Home Media Server. The user can select their Home Media Server type from a drop-down list or known Media Servers, at which point the
richt@215
  1326
               Web page sends a request to the user agent to connect with the associated service type (and, optionally, the associated event type) of the Home Media Server. The communiciation protocols supported by Home Media Servers typically vary
richt@215
  1327
               between UPnP, JSON-RPC, Protocol Buffers or other messaging formats depending on the Home Media Server requested. The Web page is able to communicate with the user-selected Home Media
richt@215
  1328
               Server in the messaging format supported by that Device, which, in this example is a simple key/value pair text format.
richt@215
  1329
            </li>
richt@215
  1330
           </ul>
richt@215
  1331
         </li>
richt@215
  1332
richt@215
  1333
         <li>
richt@215
  1334
           Web pages should not be able to communicate with Local-networked Services that have not been authorized by the user thereby maintaining the user's privacy.
richt@215
  1335
           <ul class="rule">
richt@215
  1336
            <li>
richt@215
  1337
               Example: A Web page requests access to one type of Local-networked service. The user authorizes access to that particular service. Other services running on that same device, and on other devices
richt@215
  1338
               within the network, should not be accessible to the current Web page.
richt@215
  1339
            </li>
richt@215
  1340
           </ul>
richt@215
  1341
         </li>
richt@215
  1342
richt@215
  1343
         <li>
richt@215
  1344
           A user should be able to share one or more Local-networked Services based on a particular service type request from a Web page.
richt@215
  1345
           <ul class="rule">
richt@215
  1346
            <li>
richt@215
  1347
               Example: A Web page is capable of interacting with a specific profile of Local-networked Service. As such, it makes a request to the user agent to access those services, of which multiple matches
richt@215
  1348
               are found. The user is capable of selecting one or more of the discovered services to share with the Web page. The Web page can then implement a drag-and-drop interface for the user to drag specific
richt@215
  1349
               actions on to one or more of the authorized Local-networked Services.
richt@215
  1350
            </li>
richt@215
  1351
           </ul>
richt@215
  1352
         </li>
richt@215
  1353
richt@215
  1354
         <li>
richt@215
  1355
           User agents should provide an API exposed to script that exposes the features above. The user is notified by UI anytime interaction with Local-networked Services is requested, giving the user
richt@215
  1356
           full ability to cancel or abort the transaction. The user selects the Local-networked Services to be connected to the current Web page, and can cancel these at any time. No invocations to
richt@215
  1357
           these APIs occur silently without user intervention.
richt@215
  1358
         </li>
richt@215
  1359
      </ul>
richt@215
  1360
    </section>
richt@215
  1361
richt@215
  1362
          <section class="informative appendix">
richt@215
  1363
             <h3>Examples</h3>
richt@215
  1364
richt@215
  1365
           <div class="example">
richt@215
  1366
            <p>This sample code exposes a button. When clicked, this button is disabled and the user is prompted to offer a network service. The user may also select multiple network services. When the user has authorized a network service to be connected to the web page then the web page issues a simple command to get a list of all the albums stored on the connected media player service.
richt@215
  1367
            <p>The button is re-enabled only when the connected network service disconnects for whatever reason (the service becomes unavailable on the network, the user disconnects from their current network or the user revokes access to the service from the current web page). At this point the user can re-click the button to select a new network service to connect to the web page and the above steps are repeated.</p>
richt@215
  1368
            <p>The provided service type identifier and service interaction used in this example is based on the well-defined service type and messaging format supported by the <a href="http://xbmc.org/about/">XBMC Media Server</a>. </p>
richt@215
  1369
            <hr />
richt@215
  1370
            <pre class="highlight">&lt;input type="button" value="Start" onclick="start()" id="startBtn"/&gt;
richt@215
  1371
&lt;div id="debugconsole">&lt;/div>
richt@215
  1372
richt@215
  1373
&lt;script>
richt@215
  1374
 var startBtn = document.getElementById('startBtn'),
richt@215
  1375
     debug = document.getElementById('debugconsole');
richt@215
  1376
richt@215
  1377
 function start() {
richt@215
  1378
   if(navigator.getNetworkServices) {
richt@215
  1379
      navigator.getNetworkServices('zeroconf:_xbmc-jsonrpc._tcp', gotXBMCService, error);
richt@215
  1380
      startBtn.disabled = true;
richt@215
  1381
   } else {
richt@215
  1382
      debug.innerHTML += "&lt;br&gt;Service Discovery not supported!";
richt@215
  1383
   }
richt@215
  1384
 }
richt@215
  1385
richt@215
  1386
 function gotXBMCService(services) {
richt@215
  1387
richt@215
  1388
// Listen for service disconnect messages
richt@215
  1389
richt@215
  1390
   services[0].addEventListener('serviceoffline', function ( e ) {
richt@215
  1391
       debug.innerHTML += "&lt;br>" + services[0].name + " disconnected.";
richt@215
  1392
       startBtn.disabled = false;
richt@215
  1393
   }, false);
richt@215
  1394
richt@215
  1395
// Send a service message to get albums list (and process the service response)
richt@215
  1396
richt@215
  1397
   var svcXhr = new XMLHttpRequest();
richt@215
  1398
   svcXhr.open("POST", services[0].url + "/getAlbums"); // services[0].url and its subresources have been
richt@215
  1399
                                                        // whitelisted for cross-site XHR use in this
richt@215
  1400
                                                        // current browsing context.
richt@215
  1401
richt@215
  1402
   svcXhr.setRequestHeader('Content-Type', 'application/json-rpc');
richt@215
  1403
richt@215
  1404
   svcXhr.addEventListener('readystatechange', function ( response ) {
richt@215
  1405
     if( response.readyState != 4 || response.status != 200 )
richt@215
  1406
        return;
richt@215
  1407
     debug.innerHTML += "&lt;br>" + services[0].name + " response received: ";
richt@215
  1408
     debug.textContent += JSON.parse(response.responseText);
richt@215
  1409
   }, false);
richt@215
  1410
richt@215
  1411
   var svcMsg = [
richt@215
  1412
     { "jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "genreid": -1,
richt@215
  1413
         "artistid": -1, "start": -1, "end": -1 }, "id": "1" }
richt@215
  1414
   ];
richt@215
  1415
richt@215
  1416
   svcXhr.send(JSON.stringify(svcMsg));
richt@215
  1417
   debug.innerHTML += "&lt;br>" + services[0].name + " request sent: ";
richt@215
  1418
   debug.textContent += JSON.stringify(svcMsg);
richt@215
  1419
richt@215
  1420
 }
richt@215
  1421
richt@215
  1422
 function error( err ) {
richt@215
  1423
   debug.innerHTML += "&lt;br>An error occurred obtaining a local network service.";
richt@215
  1424
   startBtn.disabled = false;
richt@215
  1425
 }
richt@215
  1426
&lt;/script></pre>
richt@215
  1427
           </div>
richt@215
  1428
richt@215
  1429
           <div class="example">
richt@215
  1430
            <p>
richt@215
  1431
             This sample exposes a drop-down list containing a number of common Home-based audio devices. When the user selects an audio device from the list provided, they are prompted to authorize a network service
richt@215
  1432
             based on the service type requested. The user may also select multiple network services matching the selected service type.
richt@215
  1433
             In this example, the user selects their make as being <var>Sony</var> and their model as being <var>Bravia S1000</var> from which the Web page can derive a service type
richt@215
  1434
             (<var>urn:schemas-upnp-org:service:RenderingControl:1</var>).
richt@215
  1435
             <br /><br />Once the user has authorized the device, the web page sends a simple mute command according to the messaging format supported by the device.
richt@215
  1436
            </p>
richt@215
  1437
            <hr />
richt@215
  1438
            <pre class="highlight">&lt;select name="make" id="make"&gt;
richt@215
  1439
  &lt;option selected="selected" disabled="disabled"&gt;Select make&lt;/option&gt;
richt@215
  1440
  &lt;option&gt;Sony&lt;/option&gt;
richt@215
  1441
  &lt;option&gt;Philips&lt;/option&gt;
richt@215
  1442
  &lt;option&gt;Alba&lt;/option&gt;
richt@215
  1443
&lt;/select&gt;
richt@215
  1444
&lt;select name="model" id="model"&gt;&lt;/select&gt;
richt@215
  1445
&lt;div id="debugconsole"&gt;&lt;/div&gt;
richt@215
  1446
richt@215
  1447
&lt;script&gt;
richt@215
  1448
  var debug = document.getElementById('debugconsole');
richt@215
  1449
richt@215
  1450
  var models = {
richt@215
  1451
    "Sony": [
richt@215
  1452
      {"name": "Bravia TV S1000", "type": "upnp", "service": "urn:schemas-upnp-org:service:RenderingControl:1" },
richt@215
  1453
      {"name": "Bravia TV S2000", "type": "zeroconf", "service": "_mediarenderer._http._tcp" },
richt@215
  1454
      {"name": "HiFi WD10", "type": "upnp", "service": "urn:schemas-upnp-org:service:RenderingControl:1" }
richt@215
  1455
    ],
richt@215
  1456
    "Philips": [ /* ... */ ],
richt@215
  1457
    "Alba": [ /* ... */ ]
richt@215
  1458
  };
richt@215
  1459
richt@215
  1460
  var makeEl = document.getElementById("make"),
richt@215
  1461
      modelEl = document.getElementById("model");
richt@215
  1462
richt@215
  1463
  makeEl.addEventListener('change', function() {
richt@215
  1464
    modelEl.innerHTML = ""; // reset
richt@215
  1465
    var defaultOption = document.createElement("option");
richt@215
  1466
    defaultOption.textContent = "Select model";
richt@215
  1467
    defaultOption.setAttribute("disabled", "disabled");
richt@215
  1468
    defaultOption.setAttribute("selected", "selected");
richt@215
  1469
    modelEl.appendChild(defaultOption);
richt@215
  1470
    for(var i = 0, l = models[makeEl.value].length; i < l; i++) {
richt@215
  1471
      var option = document.createElement("option");
richt@215
  1472
      option.textContent = models[makeEl.value][i]["name"];
richt@215
  1473
      option.setAttribute("value", models[makeEl.value][i]["type"] + ":" + models[makeEl.value][i]["service"]);
richt@215
  1474
      modelEl.appendChild(option);
richt@215
  1475
    }
richt@215
  1476
  }, false);
richt@215
  1477
richt@215
  1478
  modelEl.addEventListener('change', function() {
richt@215
  1479
    if(navigator.getNetworkServices &&
richt@215
  1480
         modelEl.value == "upnp:urn:schemas-upnp-org:service:RenderingControl:1") {
richt@215
  1481
      navigator.getNetworkServices(modelEl.value, successCallback, errorCallback);
richt@215
  1482
    } else if (modelEl.value == "zeroconf:_mediarenderer._http._tcp") {
richt@215
  1483
      debug.innerHTML += "&lt;br&gt;Service type is not implemented by this application.";
richt@215
  1484
    } else {
richt@215
  1485
      debug.innerHTML += "&lt;br&gt;Service Discovery is not supported!";
richt@215
  1486
    }
richt@215
  1487
  }, false);
richt@215
  1488
&lt;/script&gt;
richt@215
  1489
richt@215
  1490
&lt;script&gt;
richt@215
  1491
  function successCallback( services ) {
richt@215
  1492
richt@215
  1493
  // Listen for service push notification messages
richt@215
  1494
richt@215
  1495
    services[0].addEventListener('notify', function ( msg ) {
richt@215
  1496
         debug.innerHTML += "&lt;br>" + services[0].name + " event received: ";
richt@215
  1497
         debug.textContent += msg.data;
richt@215
  1498
    }, false);
richt@215
  1499
richt@215
  1500
 // Send a control signal to mute the service audio
richt@215
  1501
richt@215
  1502
    var svcXhr = new XMLHttpRequest();
richt@215
  1503
    svcXhr.open("POST", services[0].url); // services[0].url and its
richt@215
  1504
                                          // subresources have been whitelisted for
richt@215
  1505
                                          // cross-site XHR use in this current
richt@215
  1506
                                          // browsing context.
richt@215
  1507
richt@215
  1508
    svcXhr.setRequestHeader('SOAPAction', 'urn:schemas-upnp-org:service:RenderingControl:1#SetMute');
richt@215
  1509
    svcXhr.setRequestHeader('Content-Type', 'text/xml; charset="utf-8";');
richt@215
  1510
richt@215
  1511
    svcXhr.onreadystatechange = function ( response ) {
richt@215
  1512
      if( response.readyState != 4 || response.status != 200 )
richt@215
  1513
        return;
richt@215
  1514
      debug.innerHTML += "&lt;br&gt;" + services[0].name + " response received: ";
richt@215
  1515
      debug.textContent += response.responseXML;
richt@215
  1516
    }
richt@215
  1517
richt@215
  1518
    // Service messaging to mute the provided service
richt@215
  1519
    var svcMsg = '&lt;?xml version="1.0" encoding="utf-8"?&gt;' +
richt@215
  1520
                 '&lt;s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" ' +
richt@215
  1521
                   'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;' +
richt@215
  1522
                   '&lt;s:Body&gt;' +
richt@215
  1523
                     '&lt;u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"&gt;' +
richt@215
  1524
                       '&lt;InstanceID&gt;0&lt;/InstanceID&gt;' +
richt@215
  1525
                       '&lt;Channel&gt;Master&lt;/Channel&gt;' +
richt@215
  1526
                       '&lt;DesiredMute&gt;true&lt;/DesiredMute&gt;' +
richt@215
  1527
                     '&lt;/u:SetMute&gt;' +
richt@215
  1528
                   '&lt;/s:Body&gt;' +
richt@215
  1529
                 '&lt;/s:Envelope&gt;';
richt@215
  1530
richt@215
  1531
    svcXhr.send(svcMsg);
richt@215
  1532
    debug.innerHTML += "&lt;br&gt;" + services[0].name + " request sent: ";
richt@215
  1533
    debug.textContent += svcMsg;
richt@215
  1534
  }
richt@215
  1535
richt@215
  1536
  function errorCallback( error ) {
richt@215
  1537
    debug.innerHTML += "&lt;br&gt;An error occurred: " + error.code;
richt@215
  1538
  }
richt@215
  1539
&lt;/script&gt;</pre>
richt@215
  1540
          </div>
richt@215
  1541
richt@215
  1542
       </section>
richt@215
  1543
richt@215
  1544
    <section>
richt@215
  1545
      <h3>Acknowledgements</h3>
richt@215
  1546
richt@215
  1547
      <p>Thanks are expressed by the editor to the following individuals for their feedback on this specification to date (in alphabetical order):
richt@215
  1548
      <br /><br />
richt@215
  1549
      Gar Bergstedt, Lars-Erik Bolstad, Cathy Chan, Hari G Kumar, Bob Lund, Giuseppe Pascale, Marcin Simonides, Clarke Stevens, Christian S&ouml;derstr&ouml;m, Mark Vickers, ...</p>
richt@215
  1550
richt@215
  1551
      <p>Thanks are also expressed by the editor to the following organizations and groups for their support in producing this specification to date (in alphabetical order):
richt@215
  1552
      <br /></br />
richt@215
  1553
      CableLabs, Opera Software ASA, W3C Device APIs Working Group, W3C Web and TV Interest Group, ...</p>
richt@215
  1554
    </section>
richt@215
  1555
</body>
richt@215
  1556
</html>