diff --git a/packages/cli/src/Push.ts b/packages/cli/src/Push.ts index 94172ac35b..97be1628be 100644 --- a/packages/cli/src/Push.ts +++ b/packages/cli/src/Push.ts @@ -23,6 +23,7 @@ export class Push { }); this.channel.on('disconnect', (channel: string, res: express.Response) => { + console.log('>> Push.disconnect'); if (res.req !== undefined) { delete this.connections[res.req.query.sessionId as string]; } @@ -39,13 +40,17 @@ export class Push { * @memberof Push */ add(sessionId: string, req: express.Request, res: express.Response) { + console.log('>> Push.add 1'); + if (this.connections[sessionId] !== undefined) { + console.log('>> Push.add 2'); // Make sure to remove existing connection with the same session // id if one exists already this.connections[sessionId].end(); this.channel.removeClient(this.connections[sessionId]); } + console.log('>> Push.add 3'); this.connections[sessionId] = res; this.channel.addClient(req, res); } @@ -63,6 +68,7 @@ export class Push { send(type: IPushDataType, data: any, sessionId?: string) { // tslint:disable-line:no-any + console.log('>> Push.send 1'); if (sessionId !== undefined && this.connections[sessionId] === undefined) { // TODO: Log that properly! console.error(`The session "${sessionId}" is not registred.`); @@ -74,10 +80,13 @@ export class Push { data, }; + console.log('>> Push.send 2'); if (sessionId === undefined) { + console.log('>> Push.send 3'); // Send to all connected clients this.channel.send(JSON.stringify(sendData)); } else { + console.log('>> Push.send 4'); // Send only to a specific client this.channel.send(JSON.stringify(sendData), [this.connections[sessionId]]); } diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 7c8716dd8c..f9110ebc53 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -230,13 +230,23 @@ class App { // Get push connections this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { + console.log({ + headers: req.headers, + method: req.method, + url: req.url, + query: req.query, + }); + if (req.url.indexOf('/rest/push') === 0) { + console.log('*** Is Push-Connect-Request'); + // TODO: Later also has to add some kind of authentication token if (req.query.sessionId === undefined) { next(new Error('The query parameter "sessionId" is missing!')); return; } + console.log('*** Push-Connection gets added'); this.push.add(req.query.sessionId as string, req, res); return; }