FPC NODE SDK
Run Unit Test
npm install && npm test
Server API
var FPC = require('fingerprint-container-node-sdk2');
var server = new FPC.Server('127.0.0.1','9090');
server.addHandler('ServiceName',function(res){
res.send({
words: "hello world!"
});
server.destroy();
});
server.on('connect',function(){
server.register();
});
server.on('register',function(){
console.log('register success');
});
Client API
var FPC = require('fingerprint-container-node-sdk2');
var client = new FPC.Client('127.0.0.1','9090');
client.on('connect',function(){
client.register();
});
client.on('register',function(){
client.eventRequest('ServiceName', {
name: 'event'
});
client.rpcRequest('ServiceName',{
name: 'rpc'
},function(body){
console.log(body);
client.destroy();
}, function(){
console.log("timeout");
},2000);
});
#ClientPool API
var FPC = require('fingerprint-container-node-sdk2');
var pool = new FPC.ClientPool({
host: '127.0.0.1',
port: 8080,
num: 5,
name: 'mis',
heartbeat: 30*1000
});
pool.acquire(function(client){
client.rpcRequest('ServiceName',{
name: 'rpc'
},function(body){
pool.release(client);
console.log(body);
}, function(){
pool.release(client);
console.log("timeout");
},2000);
});