From a6cdd96ada223dfe8d6fc859148682467e48191a Mon Sep 17 00:00:00 2001 From: Rodrigo Cabello Date: Thu, 2 Feb 2017 18:59:49 +0100 Subject: [PATCH] adding web sockets definitions --- hyco-ws/hyco-ws-tests.ts | 8 ++++---- hyco-ws/index.d.ts | 30 ++++++++++++------------------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/hyco-ws/hyco-ws-tests.ts b/hyco-ws/hyco-ws-tests.ts index d24aa85c2c..05b500d81c 100644 --- a/hyco-ws/hyco-ws-tests.ts +++ b/hyco-ws/hyco-ws-tests.ts @@ -1,10 +1,10 @@ -import * as WebSocketRelay from 'hyco-ws'; import * as WebSocket from 'ws'; +import * as AzureRelay from 'hyco-ws'; -const wss: any = WebSocketRelay.createRelayedServer( +const wss = AzureRelay.createRelayedServer( { - server: WebSocketRelay.createRelayListenUri('uri_namespace', 'uri_path'), - token: WebSocketRelay.createRelayToken( + server: AzureRelay.createRelayListenUri('uri_namespace', 'uri_path'), + token: AzureRelay.createRelayToken( 'http://exampleurl.com}', 'key_rule', 'key') diff --git a/hyco-ws/index.d.ts b/hyco-ws/index.d.ts index 413f883c1e..d6b07d4422 100644 --- a/hyco-ws/index.d.ts +++ b/hyco-ws/index.d.ts @@ -3,12 +3,12 @@ // Definitions by: Manuel Rodrigo Cabello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// -declare module 'hyco-ws' { - namespace WebSocketRelay { +import * as WebSocket from 'ws'; + +declare namespace hycows { class HybridConnectionWebSocketServer extends NodeJS.EventEmitter { constructor(options: Object); @@ -21,19 +21,13 @@ declare module 'hyco-ws' { controlChannel: WebSocket; } - interface RealyConnection { + export function createRelayedServer(options: Object, fn: (ws: WebSocket) => void): HybridConnectionWebSocketServer; + export function relayedConnect(address: string, fn: () => void): WebSocket; + export function createRelayToken(uri: string, key_name: string, key: string, expiry?: number): string; + export function appendRelayToken(uri: string, key_name: string, key: string, expiry?: number): string; + export function createRelayBaseUri(serviceBusNamespace: string, path: string): string; + export function createRelaySendUri(serviceBusNamespace: string, path: string, token?: any, id?: any): string; + export function createRelayListenUri(serviceBusNamespace: string, path: string, token?: any, id?: any): string; +} - createRelayedServer(options: Object, fn: (ws: WebSocket) => void): HybridConnectionWebSocketServer; - relayedConnect(address: string, fn: () => void): WebSocket; - createRelayToken(uri: string, key_name: string, key: string, expiry?: number): string; - appendRelayToken(uri: string, key_name: string, key: string, expiry?: number): string; - createRelayBaseUri(serviceBusNamespace: string, path: string): string; - createRelaySendUri(serviceBusNamespace: string, path: string, token?: any, id?: any): string; - createRelayListenUri(serviceBusNamespace: string, path: string, token?: any, id?: any): string; - } - } - - var RelayConnection: WebSocketRelay.RealyConnection; - - export = RelayConnection; -} \ No newline at end of file +export = hycows; \ No newline at end of file