Added ability to have loop prevention (#44)

* Added ability to have loop prevention

* Added ability to have loop prevention

---------

Co-authored-by: Peter Phelan <peterphelan@Peters-MacBook-Pro-2.local>
This commit is contained in:
peterservisbot 2023-02-14 11:28:19 +00:00 committed by GitHub
parent 01ed706891
commit fffe64dfe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,6 +120,14 @@ Node.prototype.send = function(msg) {
var msgSent = false;
var node;
if (Number.isInteger(msg.nodeSendCounter)) {
msg.nodeSendCounter += 1;
if (msg.nodeSendCounter >= msg.MAXIMUM_NODE_SEND_COUNT) {
msg.logger.info('Loop Detected, terminating conversation');
return;
}
}
if (msg === null || typeof msg === "undefined") {
return;
} else if (!util.isArray(msg)) {