diff --git a/package.json b/package.json index ab22970..b01b016 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uci/socket", - "version": "0.3.0", + "version": "0.3.1", "description": "JSON packet intra(named)/inter(TCP) host communication over socket", "main": "src", "scripts": { @@ -43,7 +43,7 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "esm": "^3.2.25", - "mocha": "^7.1.0", + "mocha": "^7.1.1", "nodemon": "^2.0.2" }, "dependencies": { diff --git a/src/socket-class.js b/src/socket-class.js index d24d0f5..2880589 100644 --- a/src/socket-class.js +++ b/src/socket-class.js @@ -155,7 +155,6 @@ export default function socketClass(Server) { let obj = {method:'create', line:54, msg:msg} log.info(obj) this.on('connection', this._connectionHandler.bind(this)) - this.emit('log:',) resolve(msg) }) @@ -412,11 +411,12 @@ export default function socketClass(Server) { stream.on('message', messageProcess.bind(this, consumer)) if (this.conPackets.length) { - // console.log({conPackets: this.conPackets, msg:'pushing preset packets to just connected consumer'}) - for (let packet of this.conPackets) { - packet._header = {type:'on connection packet', id: 'pushed'} - await this._send(consumer,packet) // send a packet command on to consumer on connection - } + setTimeout(async () => { + for (let packet of this.conPackets) { + packet._header = {type:'on connection packet', id: 'pushed'} + await this._send(consumer,packet) // send a packet command on to consumer on connection + } + },100) } @@ -431,7 +431,7 @@ export default function socketClass(Server) { // that's it. Connection is active async function messageProcess(consumer, packet) { - log.debug({method:'_listen', line:179, packet: packet, consumer:consumer.data, msg:'incoming packet on socket side'}) + this.emit('log',{level:'mcp', packet: packet, consumer:consumer.data, msg:'incoming packet on socket side'}) let res = (await this._packetProcess(clone(packet))) || {} if (Object.keys(res).length === 0) res = {