peer-dial
peer-dial is a simple Node.js module implementing the Discovery and Launch Protocol DIAL as described in the Protocol Specification Document
Dependencies
- Node.js. tested with version 0.12.4
Node.js
includes alsonpm
to install directly using npm CLI as described in setup.
Setup
- use
npm install peer-dial
to install the module.
Run Examples
- run DIAL Server Example with
node node_modules/peer-dial/test/dial-server.js
- run DIAL Client Example with
node node_modules/peer-dial/test/dial-client.js
Usage
The peer-dial
modules contains implementation for DIAL Client and Server.
For DIAL Server usage please have a look to the following example (test/dial-server.js). In this example the DIAL Server supports the "YouTube" App through DIAL. This DIAL Server should be discoverable from YouTube App on iOS or Android. Just click on the cast button in the YouTube mobile App and select the name of your device. You can extend this example to support your custum DIAL Apps. Additional configuration parameters like additionalData
, namespaces
, extraHeaders
, etc. which are not used in the YouTube DIAL App are commented in this example. peer-dial
uses these parameters to generate the UPnP device description and DIAL app description xml as defined in the DIAL Spec.
var dial = ;var http = ;var express = ;var opn = ;var app = ;var server = http;var PORT = 3000;var MANUFACTURER = "Fraunhofer FOKUS";var MODEL_NAME = "DIAL Demo Server";var apps = "YouTube": name: "YouTube" state: "stopped" allowStop: true pid: null /* additionalData: { "ex:key1":"value1", "ex:key2":"value2" }, namespaces: { "ex": "urn:example:org:2014" }*/ { ; } ;var dialServer = expressApp: app port: PORT prefix: "/dial" manufacturer: MANUFACTURER modelName: MODEL_NAME /*extraHeaders: { "X-MY_HEADER": "My Value" },*/ delegate: { var app = appsappName; return app; } { console; var app = appsappName; var pid = null; if app apppid = "run"; appstate = "starting"; app; appstate = "running"; ; } { console; var app = appsappName; if app && apppid == pid apppid = null; appstate = "stopped"; ; else ; } ;server;
When creating the DIAL Server, you can also specify an option to control what Origins are allowed under CORS. By default, CORS is disabled.
Set the origins to be allowed by providing a corsAllowedOrigins
attribute. For example,
to allow all origins:
var dialServer = new dial.Server({
...
corsAllowedOrigins: true, // allow all origins
...
});
corsAllowedOrigins
can also be set to a string, a regex, or a function. See the origin
configuration
option of the cors package for details.
For DIAL Client usage please have a look to the following example (test/dial-client.js). This example contains calls for all interfaces of DIAL Client and DIAL Device, some of them are commented like dialDevice.stopApp(...)
and dialClient.stop();
var dial = ;var dialClient = ;dialClientstart;// dialClient.stop();
API
API description coming soon. Please refer to the examples above that demonstrate the usage of all features supported in peer-dial
. Not used features are in the comments.
License
Free for non commercial use released under the GNU Lesser General Public License v3.0 , See LICENSE file.
Contact us for commecial use famecontact@fokus.fraunhofer.de
Copyright (c) 2015 Fraunhofer FOKUS