From ef6b6ef139d11e9fe25fe668e8e5b0fa0ba8a9f7 Mon Sep 17 00:00:00 2001 From: Meno Abels Date: Wed, 14 Sep 2016 15:11:22 +0200 Subject: [PATCH] Added https type to Websocket.Server (#11213) * Added https type to Websocket.Server Hi, the current typing misses to pass to the Websocket.Server server option a https Server. Cheers meno * * added a test * fix the missing typo of http(s) * improve the test --- ws/ws-tests.ts | 9 ++++++++- ws/ws.d.ts | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ws/ws-tests.ts b/ws/ws-tests.ts index a8afa8cb99..3c85d678cb 100644 --- a/ws/ws-tests.ts +++ b/ws/ws-tests.ts @@ -2,6 +2,7 @@ import * as WebSocket from 'ws'; import * as http from'http'; +import * as https from'https'; var WebSocketServer = WebSocket.Server; @@ -54,6 +55,12 @@ var WebSocketServer = WebSocket.Server; }); } +{ + new WebSocket.Server({ server: https.createServer({}) }); + new WebSocket.Server({ server: http.createServer() }); +} + + { const verifyClient = function( info: { @@ -73,4 +80,4 @@ var WebSocketServer = WebSocket.Server; wsv.on('connection', function connection(ws) { console.log(ws.protocol) }) -} \ No newline at end of file +} diff --git a/ws/ws.d.ts b/ws/ws.d.ts index 2b16bd52ea..b7ce3bd829 100644 --- a/ws/ws.d.ts +++ b/ws/ws.d.ts @@ -8,6 +8,7 @@ declare module "ws" { import * as events from 'events'; import * as http from 'http'; + import * as https from 'https'; import * as net from 'net'; class WebSocket extends events.EventEmitter { @@ -99,7 +100,7 @@ declare module "ws" { export interface IServerOptions { host?: string; port?: number; - server?: http.Server; + server?: http.Server | https.Server; verifyClient?: VerifyClientCallbackAsync | VerifyClientCallbackSync; handleProtocols?: any; path?: string;