diff --git a/types/peer-dial/index.d.ts b/types/peer-dial/index.d.ts
index 1c638ab3d4..1e01f3b287 100644
--- a/types/peer-dial/index.d.ts
+++ b/types/peer-dial/index.d.ts
@@ -1,4 +1,6 @@
-/** Declaration file generated by dts-gen */
+// Type definitions for peer-dial 0.0.7
+// Project: https://github.com/fraunhoferfokus/peer-dial
+// Definitions by: James Tooley
///
///
@@ -8,9 +10,7 @@ import * as events from "events";
import * as express from "express";
import * as uuid from "node-uuid";
-//TODO: Needs namespaces for all of this.
-
-export class Server extends events.EventEmitter{
+export class Server extends events.EventEmitter {
constructor(options: ServerOptions);
start(): void;
@@ -31,24 +31,24 @@ export interface ServerOptions {
expressApp: express.Express;
prefix: string;
port: number;
- host: string;
- uuid: uuid.UUIDOptions;
- friendlyName: string;
+ host?: string;
+ uuid?: uuid.UUIDOptions;
+ friendlyName?: string;
manufacturer: string;
modelName: string;
- maxContentLength: number;
- extraHeaders: Object;
+ maxContentLength?: number;
+ extraHeaders?: Object;
delegate: Delegate;
- corsAllowOrigins: boolean;
+ corsAllowOrigins: string | boolean;
}
-export class Delegate {
+export interface Delegate {
- getApp(appName: string) : App;
+ getApp(appName: string): App;
- launchApp(appName: string, launchData: string, callback: (data: string) => void) : void;
+ launchApp(appName: string, launchData: string, callback: (data: string) => void): void;
- stopApp(appName: string, pid: string, callback: (data: boolean) => void) : void;
+ stopApp(appName: string, pid: string, callback: (data: boolean) => void): void;
}
export interface App {
@@ -60,24 +60,34 @@ export interface App {
launch(launchData: string): void;
}
+export interface AppInfo {
+ dialVer: string;
+ name: string;
+ options: AppInfoOptions;
+ state: string;
+ xmlns: string;
+}
+
+export interface AppInfoOptions {
+ allowStop: string;
+}
+
export class Client extends events.EventEmitter {
- constructor();
+ getDialDevice(deviceDescriptionUrl: string, callback?: (data: DialDevice, err: any) => void): void;
- getDialDevice(deviceDescriptionUrl: string, callback?: (data: DialDevice, err: any) => void) : void;
+ start(): void;
- start() : void;
+ refresh(): void;
- refresh() : void;
-
- stop() : void;
+ stop(): void;
}
export class DialDevice {
constructor(deviceInfo: DeviceInfo);
- getAppInfoXml(appName: string, callback?: (data: string, err: any) => void) :void;
+ getAppInfoXml(appName: string, callback?: (data: string, err: any) => void): void;
- getAppInfo(appName: string, callback?: (data: Object, err: any) => void): void;
+ getAppInfo(appName: string, callback?: (data: AppInfo, err: any) => void): void;
launchApp(appName: string, launchData: string, contentType: string, callback?: (data: string, err: any) => void): void;
diff --git a/types/peer-dial/peer-dial-tests.ts b/types/peer-dial/peer-dial-tests.ts
index 8b13789179..72863ef647 100644
--- a/types/peer-dial/peer-dial-tests.ts
+++ b/types/peer-dial/peer-dial-tests.ts
@@ -1 +1,65 @@
+import { Server, Client, App, AppInfo, CorsOptions, ServerOptions, Delegate, DialDevice, DeviceInfo } from 'peer-dial';
+import * as express from 'express';
+
+class AppImpl implements App {
+
+ name: string;
+ state: string;
+ allowStop: boolean;
+ pid: string;
+
+ public launch(launchData: string): void{
+
+ }
+}
+
+const app = new AppImpl();
+
+class DelegateImpl implements Delegate {
+
+ public getApp(appName: string): App{
+ return app;
+ }
+
+ public launchApp(appName: string, launchData: string, callback: (data: string) => void): void{
+
+ }
+
+ public stopApp(appName: string, pid: string, callback: (data: boolean) => void): void {
+
+ }
+}
+
+const delegate = new DelegateImpl();
+
+function testServer() {
+
+ const object = new Server({
+ expressApp: express(),
+ prefix: '/dial',
+ port: 3000,
+ corsAllowOrigins: '*',
+ manufacturer: 'testing',
+ modelName: 'testing',
+ delegate: delegate
+ });
+}
+
+function testClient() {
+ const client = new Client();
+ client.on("ready", () => {
+
+ }).on('found', (deviceDescriptionUrl: string, ssdpHeaders: string) => {
+ client.getDialDevice(deviceDescriptionUrl, (dialDevice: DialDevice, err: any) => {
+ dialDevice.getAppInfo('YouTube', (appInfo: AppInfo, err: any) => {
+ if(appInfo) {
+ dialDevice.launchApp("YouTube", "something", "text/plain", (data: string, err: any) => {
+
+ });
+ }
+ });
+ });
+ });
+ client.start();
+}
\ No newline at end of file