1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Updated metadata and modified amt-lme to hook newListener for 'connect' because JS HECI is much faster than old implementation

This commit is contained in:
Bryan Roe 2020-05-28 13:30:28 -07:00
parent 40abf105ab
commit 156f22e50d
5 changed files with 38 additions and 8 deletions

View file

@ -117,6 +117,7 @@ function lme_heci(options) {
emitterUtils.createEvent('notify');
emitterUtils.createEvent('bind');
this.on('newListener', function (name, func) { if (name == 'connect' && this._LME._connected == true) { func.call(this);} });
if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
var heci = require('heci');
@ -124,10 +125,14 @@ function lme_heci(options) {
this._ObjectID = "lme";
this._LME = heci.create();
this._LME._connected = false;
this._LME.descriptorMetadata = "amt-lme";
this._LME._binded = {};
this._LME.LMS = this;
this._LME.on('error', function (e) { this.LMS.emit('error', e); });
this._LME.on('connect', function () {
this._LME.on('connect', function ()
{
this._connected = true;
this.on('data', function (chunk) {
// this = HECI
var cmd = chunk.readUInt8(0);
@ -173,6 +178,7 @@ function lme_heci(options) {
try {
// Bind a new server socket if not already present
this[name][port] = require('net').createServer();
this[name][port].descriptorMetadata = 'amt-lme (port: ' + port + ')';
this[name][port].HECI = this;
if (lme_port_offset == 0) {
this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode