0.4.0 refactor how connect packets are handled to match socket package

bump to  0.4.0 in anticipation of 3-2020 deplogyment of light code
This commit is contained in:
David Kebler 2020-03-15 15:48:34 -07:00
parent 84cd362751
commit aeae1df3fa
2 changed files with 11 additions and 14 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@uci/websocket",
"version": "0.3.15",
"version": "0.4.0",
"description": "JSON packet host websocket server",
"main": "src",
"scripts": {
@ -33,8 +33,8 @@
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"esm": "^3.2.25",
"mocha": "^6.2.2",
"nodemon": "^2.0.0"
"mocha": "^7.1.0",
"nodemon": "^2.0.2"
},
"dependencies": {
"@uci-utils/logger": "0.0.16",
@ -42,6 +42,7 @@
"better-try-catch": "^0.6.2",
"clone": "^2.1.2",
"death": "^1.1.0",
"ws": "^7.2.0"
"p-reflect": "^2.1.0",
"ws": "^7.2.3"
}
}

View file

@ -34,7 +34,7 @@ class Socket extends Server {
this.pingInterval = opts.pingInterval === false ? opts.pingInterval : (opts.pingInterval * 1000 || 5000)
this.nextconsumerID = 0 // incrementer for default initial consumer ID
this.consumers = new Map()
this.conPackets = opts.conPackets || opts.conPacket
this.conPackets = opts.conPackets || [opts.conPacket]
this.errors = []
this.errorCount = 0
this.create = this.create.bind(this)
@ -287,15 +287,11 @@ class Socket extends Server {
}
}
if (this.conPackets) {
this.conPackets = Array.isArray(this.conPackets) ? this.conPackets : [this.conPackets]
log.debug({method:'_listen', line:171, conPackets: this.conPackets, msg:'pushing a preset packets to just connected consumer'})
this.conPackets.forEach(packet => {
if (packet) {
packet._header = {type:'on connection packet', id: 'pushed'}
this._send(consumer,packet) // send a packet command on to consumer on connection
}
})
if (this.conPackets.length) {
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
}
}
this.emit('connection:consumer',{state:'connected', name:consumer.name, id:consumer.id})