Add some Monitor event Extenders

merge-requests/43/head
Moe 2018-12-12 14:56:29 -08:00
parent e13eef5390
commit afdedbeea8
2 changed files with 43 additions and 2 deletions

View File

@ -62,6 +62,21 @@ module.exports = function(s,config){
s.onMonitorInitExtensions.push(callback)
}
//
s.onMonitorStartExtensions = []
s.onMonitorStart = function(callback){
s.onMonitorStartExtensions.push(callback)
}
//
s.onMonitorStopExtensions = []
s.onMonitorStop = function(callback){
s.onMonitorStopExtensions.push(callback)
}
//
s.onMonitorUnexpectedExitExtensions = []
s.onMonitorUnexpectedExit = function(callback){
s.onMonitorUnexpectedExitExtensions.push(callback)
}
//
s.onDetectorNoTriggerTimeoutExtensions = []
s.onDetectorNoTriggerTimeout = function(callback){
s.onDetectorNoTriggerTimeoutExtensions.push(callback)
@ -72,4 +87,15 @@ module.exports = function(s,config){
s.onFfmpegCameraStringCreationExtensions.push(callback)
}
//
s.onMonitorPingFailedExtensions = []
s.onMonitorPingFailed = function(callback){
s.onMonitorPingFailedExtensions.push(callback)
}
///////// SYSTEM ////////
s.onProcessReadyExtensions = []
s.onProcessReady = function(callback){
s.onProcessReadyExtensions.push(callback)
}
//
}

View File

@ -741,6 +741,9 @@ module.exports = function(s,config,lang){
}
s.fatalCameraError(e,'Process Unexpected Exit');
s.orphanedVideoCheck(e,2,null,true)
s.onMonitorUnexpectedExitExtensions.forEach(function(extender){
extender(Object.assign(s.group[e.ke].mon_conf[e.id],{}),e)
})
}
}
s.group[e.ke].mon[e.id].spawn.on('end',s.group[e.ke].mon[e.id].spawn_exit)
@ -1094,11 +1097,17 @@ module.exports = function(s,config,lang){
){
s.cameraFilterFfmpegLog(e)
}
s.onMonitorStartExtensions.forEach(function(extender){
extender(Object.assign(s.group[e.ke].mon_conf[e.id],{}),e)
})
}else{
s.onMonitorPingFailedExtensions.forEach(function(extender){
extender(Object.assign(s.group[e.ke].mon_conf[e.id],{}),e)
})
s.userLog(e,{type:lang["Ping Failed"],msg:lang.skipPingText1});
s.fatalCameraError(e,"Ping Failed");return;
}
}
}
}
if(
e.type !== 'socket' &&
e.type !== 'dashcam' &&
@ -1136,6 +1145,9 @@ module.exports = function(s,config,lang){
if(o.success === true){
startVideoProcessor()
}else{
s.onMonitorPingFailedExtensions.forEach(function(extender){
extender(Object.assign(s.group[e.ke].mon_conf[e.id],{}),e)
})
s.userLog(e,{type:lang["Ping Failed"],msg:lang.skipPingText1});
s.fatalCameraError(e,"Ping Failed");return;
}
@ -1399,6 +1411,9 @@ module.exports = function(s,config,lang){
var wantedStatus = lang.Idle
}
s.sendMonitorStatus({id:e.id,ke:e.ke,status:wantedStatus})
s.onMonitorStopExtensions.forEach(function(extender){
extender(Object.assign(s.group[e.ke].mon_conf[e.id],{}),e)
})
break;
case'start':case'record'://watch or record monitor url
s.initiateMonitorObject({ke:e.ke,mid:e.id})