-
Notifications
You must be signed in to change notification settings - Fork 0
/
Overview.html
1936 lines (1661 loc) · 86.8 KB
/
Overview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Networked Service Discovery and Messaging</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
<!-- This spec has been compiled with ReSpec v2 -->
<script type="text/javascript" class='remove'>
var respecConfig = {
specStatus: "unofficial",
shortName: "discovery",
edDraftURI: "http://dev.w3.org/2009/dap/discovery/",
editors: [
{ name: "Rich Tibbett",
//url: "http://richt.me/",
company: "Opera Software ASA",
companyURL: "http://opera.com/" },
{ name: "Clarke Stevens",
//url: "",
company: "CableLabs",
companyURL: "http://cablelabs.com/"
}
],
//extraCSS: ["./css/respec2.css"],
noIDLIn: true,
wg: "Device APIs and Policy Working Group",
wgURI: "http://www.w3.org/2009/dap/",
wgPublicList: "public-device-apis",
wgPatentURI: "http://www.w3.org/2004/01/pp-impl/43696/status",
};
</script>
<style type="text/css">
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (July 02 2010)
*
* @copyright
* Copyright (C) 2004-2010 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
.syntaxhighlighter a,
.syntaxhighlighter div,
.syntaxhighlighter code,
.syntaxhighlighter table,
.syntaxhighlighter table td,
.syntaxhighlighter table tr,
.syntaxhighlighter table tbody,
.syntaxhighlighter table thead,
.syntaxhighlighter table caption,
.syntaxhighlighter textarea {
-moz-border-radius: 0 0 0 0 !important;
-webkit-border-radius: 0 0 0 0 !important;
background: none !important;
border: 0 !important;
bottom: auto !important;
float: none !important;
height: auto !important;
left: auto !important;
line-height: 1.1em !important;
margin: 0 !important;
outline: 0 !important;
overflow: visible !important;
padding: 0 !important;
position: static !important;
right: auto !important;
text-align: left !important;
top: auto !important;
vertical-align: baseline !important;
width: auto !important;
box-sizing: content-box !important;
font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important;
font-weight: normal !important;
font-style: normal !important;
font-size: 1em !important;
min-height: inherit !important;
min-height: auto !important;
}
.syntaxhighlighter {
width: 100% !important;
margin: 1em 0 1em 0 !important;
position: relative !important;
overflow: auto !important;
font-size: 0.8em !important;
}
.syntaxhighlighter.source {
overflow: hidden !important;
}
.syntaxhighlighter .bold {
font-weight: bold !important;
}
.syntaxhighlighter .italic {
font-style: italic !important;
}
.syntaxhighlighter .line {
white-space: pre !important;
}
.syntaxhighlighter table {
width: 100% !important;
}
.syntaxhighlighter table caption {
text-align: left !important;
padding: .5em 0 0.5em 1em !important;
}
.syntaxhighlighter table td.code {
width: 100% !important;
}
.syntaxhighlighter table td.code .container {
position: relative !important;
}
.syntaxhighlighter table td.code .container textarea {
box-sizing: border-box !important;
position: absolute !important;
left: 0 !important;
top: 0 !important;
width: 100% !important;
height: 100% !important;
border: none !important;
padding-left: 1em !important;
overflow: hidden !important;
white-space: pre !important;
}
.syntaxhighlighter table td.gutter .line {
text-align: right !important;
padding: 0 0.5em 0 1em !important;
}
.syntaxhighlighter table td.code .line {
padding: 0 1em !important;
}
.syntaxhighlighter.nogutter td.code .container textarea, .syntaxhighlighter.nogutter td.code .line {
padding-left: 0em !important;
}
.syntaxhighlighter.show {
display: block !important;
}
.syntaxhighlighter.collapsed table {
display: none !important;
}
.syntaxhighlighter.collapsed .toolbar {
padding: 0.1em 0.8em 0em 0.8em !important;
font-size: 1em !important;
position: static !important;
width: auto !important;
height: auto !important;
}
.syntaxhighlighter.collapsed .toolbar span {
display: inline !important;
margin-right: 1em !important;
}
.syntaxhighlighter.collapsed .toolbar span a {
padding: 0 !important;
display: none !important;
}
.syntaxhighlighter.collapsed .toolbar span a.expandSource {
display: inline !important;
}
.syntaxhighlighter .toolbar {
position: absolute !important;
right: 1px !important;
top: 1px !important;
width: 11px !important;
height: 11px !important;
font-size: 10px !important;
z-index: 10 !important;
}
.syntaxhighlighter .toolbar span.title {
display: inline !important;
}
.syntaxhighlighter .toolbar a {
display: block !important;
text-align: center !important;
text-decoration: none !important;
padding-top: 1px !important;
}
.syntaxhighlighter .toolbar a.expandSource {
display: none !important;
}
.syntaxhighlighter.ie {
font-size: .9em !important;
padding: 1px 0 1px 0 !important;
}
.syntaxhighlighter.ie .toolbar {
line-height: 8px !important;
}
.syntaxhighlighter.ie .toolbar a {
padding-top: 0px !important;
}
.syntaxhighlighter.printing .line.alt1 .content,
.syntaxhighlighter.printing .line.alt2 .content,
.syntaxhighlighter.printing .line.highlighted .number,
.syntaxhighlighter.printing .line.highlighted.alt1 .content,
.syntaxhighlighter.printing .line.highlighted.alt2 .content {
background: none !important;
}
.syntaxhighlighter.printing .line .number {
color: #bbbbbb !important;
}
.syntaxhighlighter.printing .line .content {
color: black !important;
}
.syntaxhighlighter.printing .toolbar {
display: none !important;
}
.syntaxhighlighter.printing a {
text-decoration: none !important;
}
.syntaxhighlighter.printing .plain, .syntaxhighlighter.printing .plain a {
color: black !important;
}
.syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a {
color: #008200 !important;
}
.syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a {
color: blue !important;
}
.syntaxhighlighter.printing .keyword {
color: #006699 !important;
font-weight: bold !important;
}
.syntaxhighlighter.printing .preprocessor {
color: gray !important;
}
.syntaxhighlighter.printing .variable {
color: #aa7700 !important;
}
.syntaxhighlighter.printing .value {
color: #009900 !important;
}
.syntaxhighlighter.printing .functions {
color: #ff1493 !important;
}
.syntaxhighlighter.printing .constants {
color: #0066cc !important;
}
.syntaxhighlighter.printing .script {
font-weight: bold !important;
}
.syntaxhighlighter.printing .color1, .syntaxhighlighter.printing .color1 a {
color: gray !important;
}
.syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a {
color: #ff1493 !important;
}
.syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a {
color: red !important;
}
.syntaxhighlighter.printing .break, .syntaxhighlighter.printing .break a {
color: black !important;
}
</style>
<style type="text/css">
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (July 02 2010)
*
* @copyright
* Copyright (C) 2004-2010 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
.syntaxhighlighter {
background-color: none !important;
}
.syntaxhighlighter .line.alt1 {
background-color: none !important;
}
.syntaxhighlighter .line.alt2 {
background-color: none !important;
}
.syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {
background-color: none !important;
}
.syntaxhighlighter .line.highlighted.number {
color: black !important;
}
.syntaxhighlighter table caption {
color: black !important;
}
.syntaxhighlighter .gutter {
color: #afafaf !important;
}
.syntaxhighlighter .gutter .line {
border-right: 3px solid #6ce26c !important;
}
.syntaxhighlighter .gutter .line.highlighted {
background-color: #6ce26c !important;
color: white !important;
}
.syntaxhighlighter.printing .line .content {
border: none !important;
}
.syntaxhighlighter.collapsed {
overflow: visible !important;
}
.syntaxhighlighter.collapsed .toolbar {
color: blue !important;
background: none !important;
border: 1px solid #6ce26c !important;
}
.syntaxhighlighter.collapsed .toolbar a {
color: blue !important;
}
.syntaxhighlighter.collapsed .toolbar a:hover {
color: red !important;
}
.syntaxhighlighter .toolbar {
color: white !important;
background: #6ce26c !important;
border: none !important;
}
.syntaxhighlighter .toolbar a {
color: white !important;
}
.syntaxhighlighter .toolbar a:hover {
color: black !important;
}
.syntaxhighlighter .plain, .syntaxhighlighter .plain a {
color: black !important;
}
.syntaxhighlighter .comments, .syntaxhighlighter .comments a {
color: #008200 !important;
}
.syntaxhighlighter .string, .syntaxhighlighter .string a {
color: blue !important;
}
.syntaxhighlighter .keyword {
color: #006699 !important;
}
.syntaxhighlighter .preprocessor {
color: gray !important;
}
.syntaxhighlighter .variable {
color: #aa7700 !important;
}
.syntaxhighlighter .value {
color: #009900 !important;
}
.syntaxhighlighter .functions {
color: #ff1493 !important;
}
.syntaxhighlighter .constants {
color: #0066cc !important;
}
.syntaxhighlighter .script {
font-weight: bold !important;
color: #006699 !important;
background-color: none !important;
}
.syntaxhighlighter .color1, .syntaxhighlighter .color1 a {
color: gray !important;
}
.syntaxhighlighter .color2, .syntaxhighlighter .color2 a {
color: #ff1493 !important;
}
.syntaxhighlighter .color3, .syntaxhighlighter .color3 a {
color: red !important;
}
.syntaxhighlighter .keyword {
font-weight: bold !important;
}
</style>
<script src="tools/syntaxhighlighter/js/shCore.js" type="text/javascript" class='remove'></script>
<script src="tools/syntaxhighlighter/js/shAutoloader.js" type="text/javascript" class='remove'></script>
<script src="tools/syntaxhighlighter/js/shBrushXml.js" type="text/javascript" class='remove'></script>
<script src="tools/syntaxhighlighter/js/shBrushJScript.js" type="text/javascript" class='remove'></script>
<script src='./js/profiles/w3c-common-loader.js' type="text/javascript" class='remove'></script>
<style type="text/css">
/* Custom CSS optimizations (Richard Tibbett) */
/* Add better spacing to sections */
section, .section { margin-bottom: 2em; }
/* Reduce note & issue render size */
.note, .issue { font-size:0.8em; }
/* Add addition spacing to <ol> and <ul> for rule definition */
ol.rule li, ul.rule li { padding:0.6em; }
pre.widl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
pre.widl :link, pre.widl :visited { color: #000; background: transparent; }
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 }
div.example { border: solid thin red; background: #F7DFE5; color: black; padding: 0.5em 1em; position: relative; margin: 1em 0 1em 4.6em; width: auto; }
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 }
dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
dl.domintro dd p { margin: 0.5em 0; }
dl.domintro code {font-size: inherit; font-style: italic; }
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; }
</style>
</head>
<body>
<section id='abstract'>
<p>
This specification defines a mechanism for an HTML document to discover and subsequently communicate with <acronym title="Hypertext Transfer Protocol">HTTP</acronym>-based services
advertised via common discovery protocols within a user's network.
</p>
</section>
<section id='sotd'>
<p>
This document represents the early consensus of the group on the scope and features of the proposed
API.
</p>
</section>
<section class="informative">
<h3>Introduction</h3>
<p>To enable Web pages to connect and communicate with Local-networked Services provided over HTTP, this specification introduces the
<a href="#navigatornetworkservice"><code>NavigatorNetworkService</code></a> interface.</p>
<p>
Using this <acronym title="Application Programming Interface">API</acronym> 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,
is expected before the web page is able to interact with any Local-networked Services.
</p>
<p>
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.
</p>
<p>
The user agent, having captured all advertised services on the network from the Service Discovery mechanisms included in this recommendation, attempts to match
the requested service type to a discovered service according to the processing described herein.
</p>
<p>
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.
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.
</p>
<p>
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
authorized via the provided API.
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
connected Local-networked Service.
</p>
<div class="example">
<p>Example of requesting a DNS-SD advertised service:</p>
<hr />
<pre class="brush:js">function showServices( servicesList ) {
// Show a list of all the services provided to the web page
for(var i in servicesList.services) console.log( servicesList.services[i].name );
}
navigator.getNetworkServices('_boxee-jsonrpc._tcp', showServices);</pre>
</div>
<div class="example">
<p>Example of requesting a UPnP advertised service, also handling error conditions:</p>
<hr />
<pre class="brush:js">function showServices( servicesList ) {
// Show a list of all the services provided to the web page
for(var i in servicesList.services) console.log( servicesList.services[i].name );
}
function error( e ) {
console.log( "Error occurred: " + e.code );
}
navigator.getNetworkServices('urn:schemas-upnp-org:service:ContentDirectory:1', showServices, error);</pre>
</div>
<div class="example">
<p>Example of requesting either a DNS-SD or UPnP advertised service:</p>
<hr />
<pre class="brush:js">function showServices( servicesList ) {
// Show a list of all the services provided to the web page (+ service type)
for(var i in servicesList.services)
console.log( servicesList.services[i].name + '(' + servicesList.services[i].type + ')' );
}
navigator.getNetworkServices([
'_boxee-jsonrpc._tcp',
'urn:schemas-upnp-org:service:ContentDirectory:1'
], showServices);</pre>
</div>
<p>For more detailed examples see the <a href="#examples">Examples</a> section.
</section>
<section
id='conformance'>
<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
meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.</p>
<p>
Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
</p>
<p>
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
this specification are intended to be easy to follow, and not intended to be performant.)
</p>
<p>
The only conformance class defined by this specification is user agents.
</p>
<p>
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
around platform-specific limitations.
</p>
<p>
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
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
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
is insufficient.
</p>
<section>
<h3>Dependencies</h3>
This specification relies on several other underlying specifications.
<dl>
<dt>HTML</dt>
<dd>Many fundamental concepts from HTML are used by this specification. [[!HTML5]]</dd>
<dt>WebIDL</dt>
<dd>The IDL blocks in this specification use the semantics of the WebIDL specification. [[!WEBIDL]]</dd>
</dl>
</section>
</section>
<section>
<h3>Terminology</h3>
<p>
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>".
</p>
<p>
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
other <code>Node</code> objects as defined in the DOM Core specifications. [[!DOM-CORE]]
</p>
<p>
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.
</p>
<p>
A <dfn>valid service type</dfn> is a string that only uses 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.
</p>
<p>
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.
</p>
</section>
<section>
<h2>Requesting networked services</h2>
<pre class="widl">
module window {
interface [
GenerateIsReachable=ImplFrame,
OmitConstructor
] Navigator {
readonly attribute DOMString appCodeName;
readonly attribute DOMString appName;
readonly attribute DOMString appVersion;
readonly attribute DOMString language;
readonly attribute DOMString userAgent;
readonly attribute DOMString platform;
readonly attribute DOMPluginArray plugins;
readonly attribute DOMMimeTypeArray mimeTypes;
readonly attribute DOMString product;
readonly attribute DOMString productSub;
readonly attribute DOMString vendor;
readonly attribute DOMString vendorSub;
readonly attribute boolean cookieEnabled;
boolean javaEnabled();
readonly attribute boolean onLine;
void getNetworkServices(
in DOMString type,
in [Callback=FunctionOnly] NavigatorNetworkServiceSuccessCallback successCallback,
in [Callback=FunctionOnly, Optional] NavigatorNetworkServiceErrorCallback errorCallback );
void onNetworkServices(
in DOMString type,
in [Callback=FunctionOnly] NavigatorNetworkDiscoveryCallback serviceAddedCallback,
in [Callback=FunctionOnly] NavigatorNetworkDiscoveryCallback serviceRemovedCallback,
in [Callback=FunctionOnly, Optional] NavigatorNetworkServiceErrorCallback errorCallback );
void onNetworkEvent(
in DOMString type,
in [Callback=FunctionOnly] NavigatorNetworkEventCallback msgCallback,
in [Callback=FunctionOnly, Optional] NavigatorNetworkServiceErrorCallback errorCallback );
#if defined(ENABLE_GEOLOCATION) && ENABLE_GEOLOCATION
readonly attribute [EnabledAtRuntime] Geolocation geolocation;
#endif
#if defined(ENABLE_DOM_STORAGE) && ENABLE_DOM_STORAGE
void getStorageUpdates();
#endif
#if defined(ENABLE_REGISTER_PROTOCOL_HANDLER) && ENABLE_REGISTER_PROTOCOL_HANDLER
void registerProtocolHandler(in DOMString scheme, in DOMString url, in DOMString title)
raises(DomException);
#endif
#if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM
[Custom, EnabledAtRuntime] void webkitGetUserMedia(in DOMString options,
in [Callback=FunctionOnly] NavigatorUserMediaSuccessCallback successCallback,
in [Callback=FunctionOnly, Optional] NavigatorUserMediaErrorCallback errorCallback)
raises(DOMException);
#endif
};
}
</pre>
<section>
<h2>Methods</h2>
<dl class="domintro">
<dt>
<var title="">window</var>
.
<code title="dom-navigator">
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">navigator</a>
</code>
.
<code title="dom-navigator-getNetworkServices">
<a href="#dom-navigator-getnetworkservices">getNetworkServices</a>
</code>
(
<var title="">type</var>
,
<var title="">successCallback</var>
[,
<var title="">errorCallback</var>
] )
</dt>
<dd>
<p>Prompts the user to select one or more discovered network services that have advertised support for the requested service type.</p>
<p>
The
<var title="">type</var>
argument contains one or more <a>valid service type</a> tokens that the web page would like to interact with.
</p>
<p>
If the user accepts, the
<var title="">successCallback</var>
is
invoked, with one or more
<code>
<a href="#networkservice"><code>NetworkService</code></a>
</code>
objects as
its argument.
</p>
<p>
If the user declines, the
<var title="">errorCallback</var>
(if
any) is invoked.
</p>
</dd>
</dl>
<div>
<p>
When the <dfn id="dom-navigator-getnetworkservices" title="dom-navigator-getnetworkservices"><code>getNetworkServices(type, successCallback[, errorCallback])</code></dfn> method is called, the user agent MUST run the following steps:
</p>
<ol class="rule">
<li>
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> and continue to the step labeled <em>process</em> below.
</li>
<li>
Continue to the step labeled <em>failure</em> below.
</li>
<li>
<em>Process</em>: Let <var>services found</var> be an empty array.
</li>
<li>
For each <var>available service</var> in the <a>list of available service records</a> run the following steps:
<ol class="rule">
<li>
For each <var>requested service type</var> in <var>requested service types</var>: If <var>available service</var>'s <code>type</code> attribute equals the <var>requested service 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.
</li>
<li>
Continue at the next <var>available service</var>.
</li>
<li>
<em>Attach</em>: If <var>matched service</var> is not empty then run the following steps:
<ol class="rule">
<li>
Let <var>new service object</var> be a new <a href="#networkservice"><code>NetworkService</code></a> object, mapping the parameters of
<var>matched service</var> to this new object where possible.
</li>
<li>
Append <var>new service object</var> to the <var>services found</var> array.
</li>
</ol>
</li>
</ol>
</li>
<li>
If <var>services found</var> is an empty array, then jump to the step labeled <em>failure</em> below.
</li>
<li>
Return, and run the remaining steps asynchronously.
</li>
<li>
Optionally, e.g. based on a previously-established user preference, for security reasons, or due to platform limitations, jump to the step labeled <em>failure</em> below.
</li>
<li>
The user agent MUST prompt the user in a user-agent-specific manner for permission to provide the
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> with an array of
<a href="#networkservice"><code>NetworkService</code></a> objects representing the user-authorized subset of <var>services found</var>.
<p>
If the user grants permission to access one or more networked services then user agents SHOULD include an "ongoing local-network
communication" indicator.
</p>
If the user denies permission, jump to the step labeled <em>failure</em> below. If the user never responds, this algorithm stalls on this step.
</li>
<li>
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.
</li>
<li>
For each Object <var>service</var> in <var>services</var>, run the following substeps:
<ol class="rule">
<li>
Add the <var>service</var>'s <code>url</code> parameter to the <a>entry script origin's <acronym title="Uniform Resource Locator">URL</acronym> whitelist</a>.
</li>
<li>
If <var>service</var> was originally created from a UPnP discovery process 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>.
</li>
</ol>
</li>
<li>
Create a new <a href="#networkservices"><code>NetworkServices</code></a> object.
</li>
<li>
Set NetworkServices <code>servicesAvailable</code> attribute to the length of <var>services</var>.
</li>
<li>
The user agent 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
<var>services manager</var> as its argument.
</li>
<li>
The user agent MUST abort any remaining steps.
</li>
<li>
<em>Failure</em>: If <var>errorCallback</var> is null or is not an object of type <code>Function</code>, then the user agent MUST abort these steps.
</li>
<li>
Let <var>error</var> be a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
<a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
(<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>).
</li>
<li>
The user agent 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> with
<var>error</var> as its argument.
</li>
</ol>
<p>
The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#task-source" class="externalDFN">task source</a> for these
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#concept-task" class="externalDFN">tasks</a> is the
<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>.
</p>
<p>
When a <a href="#networkservice"><code>NetworkService</code></a> object is provided to a Web page, the user agent MUST add the <code>url</code> property
to the <dfn>entry script origin's URL whitelist</dfn>. This list enables the
Web page to override and initiate cross-site resource requests towards these URLs, and any sub-resources of these URLs, within the current
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
<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,
Web Messaging, XMLHttpRequest).
</p>
<p>
If the user navigates away from the current browsing context, the user agent MUST remove all previously whitelisted urls from the <a>entry script origin's URL whitelist</a>.
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:
<ul>
<li>If the current script is reloaded at any point in the same or different window.</li>
<li>if the current script reinvokes the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method at any point in its execution.</li>
<li>If the user navigates forward or back in their history to reload the current page.</li>
<li>If a script is running in a different origin.</li>
</ul>
</p>
</div>
</section>
<section>
<h3>Error Handling</h3>
<dl class="domintro">
<dt>
<var title="">error</var>
.
<code title="dom-NavigatorNetworkServiceError-code">
<a href="#dom-navigatornetworkserviceerror-code">code</a>
</code>
</dt>
<dd>
<p>
Returns the current error's error code. At this time, this will always be 1 or 2, for which the constants
<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a> and <a href="#dom-navigatornetworkserviceerror-bad_type_parameter"><code>BAD_TYPE_PARAMETER</code></a> are defined.
</p>
</dd>
</dl>
<p>
The <dfn id="dom-navigatornetworkserviceerror-code" title="dom-navigatornetworkserviceerror-code"><code>code</code></dfn> attribute of a
<a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object MUST return the code for the error, which will be the following:
</p>
<dl>
<dt>
<dfn id="dom-navigatornetworkserviceerror-permission_denied" title="dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></dfn> (numeric value 1)
</dt>
<dd>
The user denied the page permission to access any networked devices.
</dd>
</dl>
<dl>
<dt>
<dfn id="dom-navigatornetworkserviceerror-bad_type_parameter" title="dom-navigatornetworkserviceerror-bad_type_parameter"><code>BAD_TYPE_PARAMETER_ERR</code></dfn> (numeric value 2)
</dt>
<dd>
The type parameter must begin with upnp: or zeroconf:.
</dd>
</dl>
</section>
</section>
<section>
<h2>Obtaining networked services</h2>
<p>
The <a href="#networkservices"><code>NavigatorNetworkServices</code></a> interface is the top-level response object from a call to <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> and provides a set of user-authorized <a href="#networkservice"><code>NavigatorNetworkService</code></a> objects for the given request.
</p>
<pre class="widl">
module window {
interface [
CustomMarkFunction
] NavigatorNetworkServices {
// NavigatorNetworkService item(index)
[Custom] void item(in unsigned long index);
readonly attribute unsigned long length;
readonly attribute unsigned short servicesAvailable;
};
}
</pre>
<section>
<h2>Attributes</h2>
<dl class="domintro">
<dt>
<code title="dom-networkservices-services">
<a href="#dom-networkservices-services">services</a>
</code>
</dt>
<dd>
<p>
A list of one or more <a href="#networkservice"><code>NetworkService</code></a> objects representing user-selected and
user-authorized service endpoints.
</p>
</dd>
<dt>
<code title="dom-networkservices-servicesavailable">
<a href="#dom-networkservices-servicesavailable">servicesAvailable</a>
</code>
</dt>
<dd>
<p>
Returns the current number of services matching one of the app-requested <a href="#dfn-valid-service-type">valid service types</a> that are actively available within the user's current network.
</p>
</dd>
</dl>
<p>
The <dfn id="dom-networkservices-services"><code>services</code></dfn> attribute MUST return the initial list of <a href="#networkservice"><code>NetworkService</code></a> objects that have been selected as part of the algorithm for <a href="#requesting-networked-services">requesting networked
services</a>. This object is <em>immutable</em> meaning that it cannot change without the application re-invoking the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method.
</p>
<p>
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
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
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.
</p>
<div>
<p>
The <dfn id="dom-networkservices-servicesavailable"><code>servicesAvailable</code></dfn> attribute MUST return the number of services available in the
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.
By default, <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> MUST be set to <code>1</code>.
</p>
<p>
When a previously unknown instance of a networked service matching one or 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 fire a new simple
event at the <a href="#dom-networkservices-onserviceavailable"><code>onserviceavailable</code></a> event handler.
</p>
<p>
When a previously known instance of a networked service matching one or 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 fire a new simple
event at the <a href="#dom-networkservices-onserviceunavailable"><code>onserviceunavailable</code></a> event handler.
</p>
</div>
</section>
<section>
<h2>Events</h2>
<p>
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:
</p>
<p>
Events are set up through the Navigator object.
</p>
<p>
<code>Navigator.onNetworkServices()</code> sets up callbacks that are called when devices are added or removed.
</p>
<p>
<code>Navigator.onNetworkEvent()</code> sets up a callback that is called when services generate events. The argument is:
</p>
<pre class="widl">
module window {
interface [
CustomMarkFunction
] NavigatorNetworkEvent {
readonly attribute DOMString propertyset; // Properties sent from event device in XML
readonly attribute DOMString uuid; // device id
readonly attribute DOMString friendlyName;
readonly attribute DOMString serviceType;
};
}