Unverified Commit 05a2d55c authored by Dan Jones's avatar Dan Jones
Browse files

feat: add stub function to handle reveived invalid

Adapter implementations can override receivedInvalid
to log or report on messages that don't pass validation
parent efd312d2
......@@ -101,7 +101,9 @@ class Adapter {
if (validation.valid) {
const type = this.protocol.getType(parsed);
this.protocol.decode(type, parsed);
}
} else {
this.protocol.receivedInvalid(parsed, validation);
}
});
return response;
})
......
......@@ -103,7 +103,9 @@ class Adapter {
if (validation.valid) {
const type = this.protocol.getType(parsed);
this.protocol.decode(type, parsed);
}
} else {
this.protocol.receivedInvalid(parsed, validation);
}
});
return response;
})
......
......@@ -80,6 +80,18 @@ class GenericProtocol {
return message;
}
/**
* Invoked on receiving an invalid message from the backbone
*
* @param {object} message
* @param {object} validation
* @returns {*}
*/
receivedInvalid(message, validation) {
return message;
}
/**
* Optionally invoked before delivering a message to the backbone
*
......
......@@ -82,6 +82,18 @@ class GenericProtocol {
return message;
}
/**
* Invoked on receiving an invalid message from the backbone
*
* @param {object} message
* @param {object} validation
* @returns {*}
*/
receivedInvalid(message, validation) {
return message;
}
/**
* Optionally invoked before delivering a message to the backbone
*
......
......@@ -101,7 +101,9 @@ export class Adapter {
if (validation.valid) {
const type = this.protocol.getType(parsed);
this.protocol.decode(type, parsed);
}
} else {
this.protocol.receivedInvalid(parsed, validation);
}
});
return response;
})
......
......@@ -80,6 +80,18 @@ export class GenericProtocol {
return message;
}
/**
* Invoked on receiving an invalid message from the backbone
*
* @param {object} message
* @param {object} validation
* @returns {*}
*/
receivedInvalid(message, validation) {
return message;
}
/**
* Optionally invoked before delivering a message to the backbone
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment