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",
"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": {

View File

@ -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 = {