From d2cb6a304513bd0640e018c6b84830e58b6dfc3c Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 24 Apr 2019 15:47:28 +0200 Subject: [PATCH] fix(core): update --- ts/smartsocket.classes.smartsocket.ts | 2 +- ts/smartsocket.classes.socketserver.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ts/smartsocket.classes.smartsocket.ts b/ts/smartsocket.classes.smartsocket.ts index 2ccd2ca..c390f1f 100644 --- a/ts/smartsocket.classes.smartsocket.ts +++ b/ts/smartsocket.classes.smartsocket.ts @@ -13,7 +13,7 @@ import { SocketServer } from './smartsocket.classes.socketserver'; import * as SocketIO from 'socket.io'; export interface ISmartsocketConstructorOptions { - port: number; + port?: number; } export class Smartsocket { diff --git a/ts/smartsocket.classes.socketserver.ts b/ts/smartsocket.classes.socketserver.ts index 9feffcc..bd6789d 100644 --- a/ts/smartsocket.classes.socketserver.ts +++ b/ts/smartsocket.classes.socketserver.ts @@ -55,7 +55,12 @@ export class SocketServer { const done = plugins.smartpromise.defer(); // handle http servers + // in case an external server has been set "this.standaloneServer" should be false if (this.httpServer && this.standaloneServer) { + if (!this.smartsocket.options.port) { + console.log('there should be a port specifed for smartsocket!') + throw new Error('there should be a port specified for smartsocket') + } this.httpServer.listen(this.smartsocket.options.port, () => { console.log(`Server started in standalone mode on ${this.smartsocket.options.port}`); done.resolve();