OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // An API for discovery of devices that support DIAL. |
| 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 docs). |
| 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 { |
| 34 |
| 35 // Represents a unique device that responded to a DIAL discovery request. |
| 36 dictionary DialDevice { |
| 37 // A label identifying the device within this instance of the browser. |
| 38 // Not guaranteed to persist beyond browser instances. |
| 39 DOMString deviceLabel; |
| 40 |
| 41 // A URL pointing to the device description file for the device. |
| 42 DOMString deviceDescriptionUrl; |
| 43 |
| 44 // The uPnP configuration ID reported by the device. Corresponds to the |
| 45 // CONFIGID.UPNP.ORG header in the M-SEARCH response. |
| 46 long? configId; |
| 47 }; |
| 48 |
| 49 callback BooleanCallback = void (boolean result); |
| 50 |
| 51 interface Functions { |
| 52 // Causes DIAL discovery to happen immediately. An onDeviceList event is |
| 53 // fired with the resulting device list. The callback is invoked with |
| 54 // |true| if discovery was successful or |false| otherwise (and |
| 55 // chrome.extension.lastError is set). |
| 56 static void discoverNow(BooleanCallback callback); |
| 57 }; |
| 58 |
| 59 interface Events { |
| 60 // Event fired to inform clients of the current set of responsive devices. |
| 61 // May be fired in response to multiple circumstances: |
| 62 // |
| 63 // (1) The DIAL service refreshed its device list through periodic polling. |
| 64 // (2) A client invoked discoverNow(). |
| 65 // (3) An event happened that should invalidate the device list |
| 66 // (e.g., a network interface went offline), in which case it is fired |
| 67 // with an empty array. |
| 68 static void onDeviceList(DialDevice[] result); |
| 69 }; |
| 70 |
| 71 }; |
OLD | NEW |