OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // An API for discovery of devices that support DIAL. | 5 // Use the <code>chrome.dial</code> API to discover devices that support DIAL. |
6 // Protocol specification: http://www.dial-multiscreen.org/ | 6 // Protocol specification: http://www.dial-multiscreen.org/ |
7 // | |
8 // The API is backed by a service that multicasts discovery requests on the | |
9 // local network to discover DIAL-capable devices and maintains a list of | |
10 // devices that have responded. Adding an onDeviceList listener causes the | |
11 // service to periodically issue discovery requests to maintain the device list. | |
12 // (No polling is done when there are no onDeviceList listeners.) | |
13 // | |
14 // The onDeviceList event is fired when discovery respnses are received and in | |
15 // other circumstances; see the documentation for onDeviceList. | |
16 // | |
17 // The client can request that network discovery can be done immediately by | |
18 // invoking discoverNow() which is useful for presenting the user with an | |
19 // updated list of devices. | |
20 // | |
21 // On-demand use (updates when discoverNow() is called): | |
22 // chrome.dial.onDeviceList.addListener(function (list) { updateMenu(list); }); | |
23 // chrome.dial.discoverNow(); | |
24 // (Remember to remove the listener when the menu closes.) | |
25 // | |
26 // Background use (updates only when periodic polling happens): | |
27 // var myList; | |
28 // chrome.dial.onDeviceList.addListener(function (list) { myList = list; }); | |
29 // | |
30 // These can be combined to poll for devices to prime the device menu, then | |
31 // refresh the menu when it is displayed. | |
32 | |
33 namespace dial { | 7 namespace dial { |
34 | 8 |
35 // Represents a unique device that responded to a DIAL discovery request. | 9 // Represents a unique device that responded to a DIAL discovery request. |
36 dictionary DialDevice { | 10 dictionary DialDevice { |
37 | 11 |
38 // A label identifying the device within this instance of the browser. | 12 // A label identifying the device within this instance of the browser. |
39 // Not guaranteed to persist beyond browser instances. | 13 // Not guaranteed to persist beyond browser instances. |
40 DOMString deviceLabel; | 14 DOMString deviceLabel; |
41 | 15 |
42 // A URL pointing to the device description resource for the device. | 16 // A URL pointing to the device description resource for the device. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // (2) A client invoked discoverNow(). | 55 // (2) A client invoked discoverNow(). |
82 // (3) An event happened that should invalidate the device list | 56 // (3) An event happened that should invalidate the device list |
83 // (e.g., a network interface went offline), in which case it is fired | 57 // (e.g., a network interface went offline), in which case it is fired |
84 // with an empty array. | 58 // with an empty array. |
85 static void onDeviceList(DialDevice[] result); | 59 static void onDeviceList(DialDevice[] result); |
86 | 60 |
87 // Event fired to inform clients on errors during device discovery. | 61 // Event fired to inform clients on errors during device discovery. |
88 static void onError(DialError error); | 62 static void onError(DialError error); |
89 }; | 63 }; |
90 }; | 64 }; |
OLD | NEW |