Child Node Framework Update : syntax fixes

montage-api
Moe 2021-11-25 09:30:23 -08:00
parent d7409db6f0
commit f336bb654a
3 changed files with 12 additions and 16 deletions

View File

@ -4,7 +4,6 @@ const https = require('https');
const express = require('express');
const { createWebSocketServer, createWebSocketClient } = require('./basic/websocketTools.js')
module.exports = function(s,config,lang,app,io){
const { cameraDestroy } = require('./monitor/utils.js')(s,config,lang)
//setup Master for childNodes
if(config.childNodes.enabled === true && config.childNodes.mode === 'master'){
const {
@ -36,12 +35,12 @@ module.exports = function(s,config,lang,app,io){
});
s.debugLog('childNodeWebsocket.attach(childNodeServer)')
//send data to child node function
s.cx = function(data,connectionId,senderObject){
s.cx = function(data,connectionId){
// if(senderObject){
// data.sentFrom = senderObject.id;
// childNodesConnectionIndex[y].sendJson(data)
// childNodesConnectionIndex[connectionId].sendJson(data)
// }else{
childNodesConnectionIndex[y].sendJson(data)
childNodesConnectionIndex[connectionId].sendJson(data)
// }
}
//child Node Websocket
@ -82,8 +81,7 @@ module.exports = function(s,config,lang,app,io){
onMessage: onDataFromMasterNode
})
function sendDataToMasterNode(data){
x.socketKey = config.childNodes.key;
childIO.send(JSON.stringify(data));
childIO.send(JSON.stringify(data))
}
s.cx = sendDataToMasterNode;
s.tx = function(x,y){

View File

@ -1,4 +1,5 @@
module.exports = function(s,config,lang,app,io){
const { cameraDestroy } = require('../monitor/utils.js')(s,config,lang)
const queuedSqlCallbacks = s.queuedSqlCallbacks;
var checkCpuInterval = null;
function onDataFromMasterNode(d) {
@ -17,7 +18,6 @@ module.exports = function(s,config,lang,app,io){
case'kill':
s.initiateMonitorObject(d.d);
cameraDestroy(d.d)
var childNodeIp = s.group[d.d.ke].activeMonitors[d.d.id]
break;
case'sync':
s.initiateMonitorObject(d.sync);
@ -46,10 +46,11 @@ module.exports = function(s,config,lang,app,io){
function initiateConnectionToMasterNode(){
console.log('CHILD CONNECTION SUCCESS')
s.cx({
f : 'init',
port : config.port,
coreCount : s.coreCount,
availableHWAccels : config.availableHWAccels
f: 'init',
port: config.port,
coreCount: s.coreCount,
availableHWAccels: config.availableHWAccels,
socketKey: config.childNodes.key
})
clearInterval(checkCpuInterval)
checkCpuInterval = setInterval(async () => {

View File

@ -10,8 +10,7 @@ module.exports = function(s,config,lang,app,io){
client.ip = ipAddress;
client.shinobiChildAlreadyRegistered = true;
client.sendJson = (data) => {
const dataString = JSON.stringify(data);
client.send(dataString)
client.send(JSON.stringify(data))
}
if(!s.childNodes[ipAddress]){
s.childNodes[ipAddress] = {}
@ -30,9 +29,7 @@ module.exports = function(s,config,lang,app,io){
childNodes : s.childNodes
})
activeNode.coreCount = options.coreCount
return {
ipAddress,
}
return ipAddress
}
function initiateVideoTransferConnection(){