|
|
@ -6,18 +6,22 @@ const axios = require('axios')
|
|
|
|
const puppeteer = require('puppeteer')
|
|
|
|
const puppeteer = require('puppeteer')
|
|
|
|
function sleep(ms) { return new Promise(r=>setTimeout(r, ms))}
|
|
|
|
function sleep(ms) { return new Promise(r=>setTimeout(r, ms))}
|
|
|
|
// [ "ecityruf", "123456789" ]
|
|
|
|
// [ "ecityruf", "123456789" ]
|
|
|
|
class eMessagePuppeteerConnector extends Connector {
|
|
|
|
class eMessagePuppeteerConnectorBase extends Connector {
|
|
|
|
constructor (amqpConnMngr) {
|
|
|
|
constructor (amqpConnMngr) {
|
|
|
|
super(amqpConnMngr)
|
|
|
|
super(amqpConnMngr)
|
|
|
|
this.name = "em-puppet"
|
|
|
|
this.name = "em-puppet"
|
|
|
|
|
|
|
|
this.defaultServiceName = ""
|
|
|
|
this.duplexCapable = true
|
|
|
|
this.duplexCapable = true
|
|
|
|
this.supportBOSkrypt = true
|
|
|
|
this.supportBOSkrypt = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async transmitMessage(msg, params) {
|
|
|
|
async transmitMessage(msg, params) {
|
|
|
|
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
|
|
|
|
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
|
|
|
|
const target = params[0]
|
|
|
|
const target = params[0]
|
|
|
|
if (target.split('#').length !== 2) throw 'No valid eMessage Parameter <serviceName#identifier>'
|
|
|
|
|
|
|
|
const serviceName = target.split('#')[ 0 ], identifier = target.split('#')[ 1 ]
|
|
|
|
const overwriteIdentifier = target.indexOf('#') > -1
|
|
|
|
|
|
|
|
//if (target.split('#').length !== 2) throw 'No valid eMessage Parameter <serviceName#identifier>'
|
|
|
|
|
|
|
|
const serviceName = overwriteIdentifier ? target.split('#')[ 0 ] : this.defaultServiceName,
|
|
|
|
|
|
|
|
identifier = overwriteIdentifier ? target.split('#')[ 1 ] : target
|
|
|
|
|
|
|
|
|
|
|
|
const $device = msg.routingParams.device
|
|
|
|
const $device = msg.routingParams.device
|
|
|
|
let payloadBuffer = Buffer.from(msg.payload)
|
|
|
|
let payloadBuffer = Buffer.from(msg.payload)
|
|
|
@ -116,4 +120,29 @@ class eMessagePuppeteerConnector extends Connector {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = eMessagePuppeteerConnector
|
|
|
|
|
|
|
|
|
|
|
|
class eMessagePuppeteerConnectorCityruf extends eMessagePuppeteerConnectorBase {
|
|
|
|
|
|
|
|
constructor (amqpConnMngr) {
|
|
|
|
|
|
|
|
super(amqpConnMngr)
|
|
|
|
|
|
|
|
this.name = "em-p-cityruf"
|
|
|
|
|
|
|
|
this.defaultServiceName = "1"
|
|
|
|
|
|
|
|
this.duplexCapable = true
|
|
|
|
|
|
|
|
this.supportBOSkrypt = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class eMessagePuppeteerConnectorTwoWays extends eMessageAlertManagerConnectorBase {
|
|
|
|
|
|
|
|
constructor (amqpConnMngr) {
|
|
|
|
|
|
|
|
super(amqpConnMngr)
|
|
|
|
|
|
|
|
this.name = "em-p-twoways"
|
|
|
|
|
|
|
|
this.defaultServiceName = "7"
|
|
|
|
|
|
|
|
this.duplexCapable = true
|
|
|
|
|
|
|
|
this.supportBOSkrypt = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
eMessagePuppeteerConnectorBase,
|
|
|
|
|
|
|
|
eMessagePuppeteerConnectorCityruf,
|
|
|
|
|
|
|
|
eMessagePuppeteerConnectorTwoWays
|
|
|
|
|
|
|
|
}
|