Commit ffc375f0 authored by Dan Jones's avatar Dan Jones
Browse files

Merge branch '18-add-stub-handler-for-received-invalid-message' into 'dev'

Resolve "Add stub handler for received invalid message"

Closes #18

See merge request !11
parents efd312d2 05a2d55c
...@@ -101,7 +101,9 @@ class Adapter { ...@@ -101,7 +101,9 @@ class Adapter {
if (validation.valid) { if (validation.valid) {
const type = this.protocol.getType(parsed); const type = this.protocol.getType(parsed);
this.protocol.decode(type, parsed); this.protocol.decode(type, parsed);
} } else {
this.protocol.receivedInvalid(parsed, validation);
}
}); });
return response; return response;
}) })
......
...@@ -103,7 +103,9 @@ class Adapter { ...@@ -103,7 +103,9 @@ class Adapter {
if (validation.valid) { if (validation.valid) {
const type = this.protocol.getType(parsed); const type = this.protocol.getType(parsed);
this.protocol.decode(type, parsed); this.protocol.decode(type, parsed);
} } else {
this.protocol.receivedInvalid(parsed, validation);
}
}); });
return response; return response;
}) })
......
...@@ -80,6 +80,18 @@ class GenericProtocol { ...@@ -80,6 +80,18 @@ class GenericProtocol {
return message; 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 * Optionally invoked before delivering a message to the backbone
* *
......
...@@ -82,6 +82,18 @@ class GenericProtocol { ...@@ -82,6 +82,18 @@ class GenericProtocol {
return message; 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 * Optionally invoked before delivering a message to the backbone
* *
......
...@@ -101,7 +101,9 @@ export class Adapter { ...@@ -101,7 +101,9 @@ export class Adapter {
if (validation.valid) { if (validation.valid) {
const type = this.protocol.getType(parsed); const type = this.protocol.getType(parsed);
this.protocol.decode(type, parsed); this.protocol.decode(type, parsed);
} } else {
this.protocol.receivedInvalid(parsed, validation);
}
}); });
return response; return response;
}) })
......
...@@ -80,6 +80,18 @@ export class GenericProtocol { ...@@ -80,6 +80,18 @@ export class GenericProtocol {
return message; 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 * 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