Skip to content

Publish messages and subscribe to message channels on Catch Service Management Gateways.

License

Notifications You must be signed in to change notification settings

catchtechnologies/catch-messaging

Repository files navigation

Catch Messaging

Publish messages and subscribe to message channels on Catch Service Management Gateways.

Requirements

This package uses (redis)[https://redis.io] pubsub for messaging and requires a local redis instance to be running.

Usage

npm i catch-messaging

var Messaging = require('catch-messaging');
const serviceName = 'Messaging Test';
const debug = true;

// Sample commands for testing.
var serviceCommands = [
  {
    endWith: "none",
    useHex: false,
    channel: "connect",
    pattern: "connect"
  }
];

// Sample responses for testing.
var serviceResponses = [
  {
    endWith: "none",
    useHex: false,
    useRegularExpression: false,
    channel: "messaging tester.connected",
    pattern: "connected",
    persist: false
  }
]

messaging = new Messaging(serviceName, serviceCommands, serviceResponses, debug, (message) => {
  console.log('New message received: ' + message);
  if(message === 'connect'){
    connect();
  }
});

function connect(){
  messaging.publish('connected');
}

About

Publish messages and subscribe to message channels on Catch Service Management Gateways.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published