GrexxConnect External System Service (ESS) Helper
Install
npm install grexxconnect-ess --save
Features
- reject messages (since v1.0.9)
- auto-reconnect (since v1.0.5)
- custom monitoring data (since v1.0.5)
- basic receiving and responding to ESS messages
Simple Example
"use strict";
const EssConnect = require('grexxconnect-ess');
const GrexxConnectEss = new EssConnect({
applicationName: "My Custom ESS v2.4",
username: "John",
password: "JohnsPassword",
server: "wss://server.com"
});
GrexxConnectEss.on('message', Message => {
console.info('Received a message', Message.parsed, Message.content);
const reversedValue = (Message.parsed.content || '').split("").reverse().join("");
Message.resolve([{
reference: 'outputField',
values: [{ value: reversedValue }]
}])
});
Full Example
"use strict";
const EssConnect = require('grexxconnect-ess');
const GrexxConnectEss = new EssConnect({
applicationName: "My Custom ESS v2.4",
username: "John",
password: "JohnsPassword",
server: "wss://server.com",
debug: true
});
GrexxConnectEss.on('message', Message => {
console.info('Received a message', Message.parsed, Message.content);
const reversedValue = (Message.parsed.content || '').split("").reverse().join("");
if( reversedValue === 'error' ) {
Message.reject('Error message for production', 'Error message for debugging', {
additionalErrorContext:"Include additional error info here"
});
} else {
Message.resolve([{
reference: 'outputField',
values: [{ value: reversedValue }]
}]);
}
});
GrexxConnectEss.setMonitoringResponse(() => {
return {
//== required. can be 'ok', 'warning', 'error'
status: 'ok',
//== Optional extra status data. Can be whatever you want.
messagesInQueue: 0,
lastMessage: '10 days ago'
};
});
GrexxConnectEss.on('authorized', serviceName => console.info('Authorized!', serviceName));
GrexxConnectEss.on('disconnected', () => console.info('Disconnected!'));
GrexxConnectEss.on('error', error => console.error('Error: ', error));