Skip to content

Commit

Permalink
Add content type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
wiresio authored Jan 9, 2020
1 parent f775403 commit 32f7879
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/binding-mqtt/src/mqtt-broker-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,16 @@ export default class MqttBrokerServer implements ProtocolServer {
if (action) {
thing.invokeAction(segments[3],
// action.invoke(
JSON.parse(payload))
function() {
let value;
try {
value = ContentSerdes.get().contentToValue({ type: packet.properties.contentType, body: Buffer.from(payload) }, action.input);
return value;
} catch(err) {
console.warn(`MqttBrokerServer at ${this.brokerURI} cannot process received message for '${segments[3]}': ${err.message}`);
return;
}
})
.then((output) => {
// MQTT cannot return results
if (output) {
Expand Down

0 comments on commit 32f7879

Please sign in to comment.