example/pong
#!/usr/bin/env node
var Logger = require('logger-facade-nodejs');
var LoggerConsolePlugin = require('logger-facade-console-plugin-nodejs');
// this is the default config
var config = {
level: 'debug',
timeFormat: 'YYYY-MM-DD HH:mm:ss',
messageFormat: '%time | %logger::%level - %msg | metadata: %metadata'
};
var plugin = new LoggerConsolePlugin(config);
Logger.use(plugin);
var ZSSClient = require('../client');
var config = {
// broker frontend address
broker: 'tcp://127.0.0.1:7777',
// service unique identifier
sid: 'PONG',
// client identity (optional), defaults to 'client'
identity: "PONG_CLIENT",
// client timeout in ms (optional), defaults to 1s
timeout: 1000
};
console.log("----- Client Start with ---- \n %j \n----------", config);
var client = new ZSSClient(config);
setInterval(function(){
console.log("----- Client Sending PING ----");
// call return a promise
client.call("ping", "ping")
.then(function(response){
console.log("----- Client Received ----\n %j \n --------------------", response);
})
.fail(function(error){
console.log("----- Client Received Error ----\n %j \n --------------------", error);
});
}, 2000);