diff --git a/browser-client.js b/browser-client.js index 7c97d6f..0dc1081 100644 --- a/browser-client.js +++ b/browser-client.js @@ -39,6 +39,14 @@ class Consumer extends EventEmitter { listen (func) { this.socket.addEventListener('message', handler.bind(this)) + this.on('pushed',async function(packet){ + // TODO do some extra security here? + let res = await this._packetProcess(packet) + if (!res) { // if process was not promise returning like just logged to console + console.log('warning: consumer process function was not promise returning') + } + }) + function handler (event) { let packet = {} if (this.socket.readyState === 1) { @@ -67,7 +75,6 @@ class Consumer extends EventEmitter { this.socket.send(message) // listen for when packet comes back with unique header id this.once(packet._header.id, async function (reply) { - // console.log('reply emitted', reply) let res = await this._packetProcess(reply) if (!res) { // if process was not promise returning like just logged to console res = reply @@ -86,6 +93,7 @@ class Consumer extends EventEmitter { async _packetProcess (packet) { return Promise.resolve(packet) } + } // end Consumer Class diff --git a/package.json b/package.json index b2dc674..e0ae89e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uci/websocket-client", - "version": "0.1.2", + "version": "0.1.3", "description": "JSON packet browser client over web socket", "main": "browser-client", "scripts": {