0.3.1 added 100ms delay to connection packet push to avoid issue where connection packet is not sent/received

master
David Kebler 2020-03-24 14:13:37 -07:00
parent 70fee6fc7c
commit 9528e71abb
2 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@uci/socket", "name": "@uci/socket",
"version": "0.3.0", "version": "0.3.1",
"description": "JSON packet intra(named)/inter(TCP) host communication over socket", "description": "JSON packet intra(named)/inter(TCP) host communication over socket",
"main": "src", "main": "src",
"scripts": { "scripts": {
@ -43,7 +43,7 @@
"chai": "^4.2.0", "chai": "^4.2.0",
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"esm": "^3.2.25", "esm": "^3.2.25",
"mocha": "^7.1.0", "mocha": "^7.1.1",
"nodemon": "^2.0.2" "nodemon": "^2.0.2"
}, },
"dependencies": { "dependencies": {

View File

@ -155,7 +155,6 @@ export default function socketClass(Server) {
let obj = {method:'create', line:54, msg:msg} let obj = {method:'create', line:54, msg:msg}
log.info(obj) log.info(obj)
this.on('connection', this._connectionHandler.bind(this)) this.on('connection', this._connectionHandler.bind(this))
this.emit('log:',)
resolve(msg) resolve(msg)
}) })
@ -412,11 +411,12 @@ export default function socketClass(Server) {
stream.on('message', messageProcess.bind(this, consumer)) stream.on('message', messageProcess.bind(this, consumer))
if (this.conPackets.length) { if (this.conPackets.length) {
// console.log({conPackets: this.conPackets, msg:'pushing preset packets to just connected consumer'}) setTimeout(async () => {
for (let packet of this.conPackets) { for (let packet of this.conPackets) {
packet._header = {type:'on connection packet', id: 'pushed'} packet._header = {type:'on connection packet', id: 'pushed'}
await this._send(consumer,packet) // send a packet command on to consumer on connection 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 // that's it. Connection is active
async function messageProcess(consumer, packet) { 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))) || {} let res = (await this._packetProcess(clone(packet))) || {}
if (Object.keys(res).length === 0) if (Object.keys(res).length === 0)
res = { res = {