Bug fixed when same listener wants to register itself twice

This commit is contained in:
Luis Fernando Molina committed 2020-04-10 12:02:22 +02:00
1 parent e66b4fbbc8
commit 9ef85f40d9
3 files changed
+17 -8

No files matched your search

+9 -5
View File
@@ -183,16 +183,20 @@
function listenToEvent(eventHandlerName, eventType, callerId, handler, extraData) {
let eventSubscriptionId = Math.trunc(Math.random() * 1000000)
let found = false
/*
We can not allow to have the exact same listener more than once. In case that we find a listener trying to listen again, the first record will
be deleted and we are just going to consider the last one comming in.
*/
for (let i = 0; i < thisObject.listeners.length; i++) {
if (eventHandlerName === thisObject.listeners[i][0] && eventType === thisObject.listeners[i][1] && callerId === thisObject.listeners[i][2]) {
found = true
thisObject.listeners.splice(i, 1)
break
}
}
if (found === false) {
thisObject.listeners.push([eventHandlerName, eventType, callerId, handler, extraData, eventSubscriptionId])
}
thisObject.listeners.push([eventHandlerName, eventType, callerId, handler, extraData, eventSubscriptionId])
return eventSubscriptionId
}
+2 -1
View File
@@ -66,7 +66,8 @@
}
if (tasks.get(message.event.taskId) !== undefined) {
//console.log('[WARN] BackendServers -> Task Manager Server -> runTask -> Task Already Running -> taskId = ' + message.event.taskId)
let key = message.event.taskName + '-' + 'Task' + '-' + message.event.taskId
eventsServerClient.raiseEvent(key, 'Running') // Meaning Task Running
return
}
//console.log('[INFO] BackendServers -> Task Manager Server -> runTask -> Task Name = ' + message.event.taskName)
@@ -19,8 +19,12 @@ function newReferenceAttachDetach () {
}
function completeDetachment (node) {
if (node.payload !== undefined && node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) {
node.payload.referenceParent.payload.uiObject.isShowing = false
if (node.payload !== undefined !== undefined) {
if (node.payload.referenceParent.payload !== undefined) {
if (node.payload.referenceParent.payload.uiObject !== undefined) {
node.payload.referenceParent.payload.uiObject.isShowing = false
}
}
}
node.payload.referenceParent = undefined