on-message.js
570 Bytes
const MODULE_NAME = 'KOMODO-SDK-PUSH-TRX.CLIENT.ON-MESSAGE';
const logger = require('tektrans-logger');
const uniqid = require('uniqid');
module.exports = (gwName, ws, data) => {
const xid = uniqid();
let msg;
try {
msg = JSON.parse(data.toString());
} catch (e) {
msg = data.toString();
}
if (msg) {
// eslint-disable-next-line no-param-reassign
ws.isAlive = true;
logger.verbose(`${MODULE_NAME} 8FD6EF07: Got a message`, {
xid,
gwName,
msg,
});
}
};