@@ -26,7 +26,7 @@ import { ICpuData, cpu } from './stats/cpu';
2626import { decodeJwt } from './security' ;
2727
2828export interface ISocketServerOptions {
29- port : number ;
29+ app : express . Application ;
3030}
3131
3232export interface IOutput {
@@ -50,7 +50,7 @@ export class SocketServer {
5050
5151 start ( ) : Observable < string > {
5252 return new Observable ( observer => {
53- this . createRxServer ( this . options )
53+ this . createRxServer ( this . options . app )
5454 . map ( data => {
5555 this . token = data . conn . protocol ;
5656 this . connectingClient = data . session ;
@@ -287,27 +287,29 @@ export class SocketServer {
287287 } ) ;
288288 }
289289
290- private createRxServer = ( options : ws . ServerOptions ) => {
290+ private createRxServer = ( appplication : any ) => {
291291 return new Observable ( ( observer : Observer < any > ) => {
292292 let config : any = getConfig ( ) ;
293+ const expressApp = appplication . app ;
293294 let server ;
294295
295296 if ( config . ssl ) {
296297 server = https . createServer ( {
297298 cert : readFileSync ( config . sslcert ) ,
298299 key : readFileSync ( config . sslkey )
299- } , express ( ) ) ;
300+ } , expressApp ) ;
300301 } else {
301- server = http . createServer ( ) ;
302+ server = http . createServer ( expressApp ) ;
302303 }
303304
304- server . listen ( options . port ) ;
305- const msg : LogMessageType = {
306- message : `[socket]: server running at port ${ options . port } ` ,
307- type : 'info' ,
308- notify : false
309- } ;
310- logger . next ( msg ) ;
305+ server . listen ( config . port , ( ) => {
306+ const msg : LogMessageType = {
307+ message : `[server]: API and Socket Server running at port ${ config . port } ` ,
308+ type : 'info' ,
309+ notify : false
310+ } ;
311+ logger . next ( msg ) ;
312+ } ) ;
311313
312314 let wss : ws . Server = new ws . Server ( {
313315 verifyClient : ( info : any , done ) => {
0 commit comments