Skip to content

Commit

Permalink
Add debug data on send/receive
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Sep 1, 2020
1 parent 3f7ab9c commit 5f2f80b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions runtime/network.js
@@ -1,5 +1,7 @@
const { server: WebSocketServer } = require('websocket');
const Base = require('noflo-runtime-base');
const debugSend = require('debug')('noflo-runtime-websocket:send');
const debugReceive = require('debug')('noflo-runtime-websocket:receive');

function normalizePayload(payload) {
if (typeof payload !== 'object' && typeof payload !== 'function') {
Expand Down Expand Up @@ -71,6 +73,7 @@ class WebSocketRuntime extends Base {
// With exported port packets we need to go one deeper
normalizedPayload.payload = normalizePayload(normalizedPayload.payload);
}
debugSend(`${protocol}:${topic}`);
context.connection.sendUTF(JSON.stringify({
protocol,
command: topic,
Expand Down Expand Up @@ -128,6 +131,7 @@ module.exports = function (httpServer, options) {
}
return;
}
debugReceive(`${contents.protocol}:${contents.command}`);
runtime.receive(contents.protocol, contents.command, contents.payload, {
connection,
});
Expand Down

0 comments on commit 5f2f80b

Please sign in to comment.