eos 的 Node.js 开发包 node-eos
第29期OSC源创会#南京#开始报名,AngularJS、Netty 等
node-eos 是 eos 的 Node.js 客户端开发包。
init eos :
var eos = require("node-eos");eos.init({ zookeeper_ip: '192.168.0.224', zookeeper_port: 2181, long_connect: true, exclude_eos:[],//ignore eos debugging_server_ip: '', //debugging server ip use_mock: true, //controll global mock mock_config_file: __dirname + "/config_mock.json" //mock config file path});
definde a eos service
module.exports = function(eos){ function testType(){ eos.Service.call(this); this.appId = "test"; this.serviceId = "testType"; this.serviceVersion = "1.3"; } eos.util.inherits(testType,eos.Service); testType.prototype.testMap = function(map,str,successFunc,errorFunc){ var req = this._createReqPro("testMap",map,str); eos.call(req,successFunc,errorFunc); } return testType;}
call service
var test = require("./testType")(eos);new test.appService().testMap({"a":"1","b":"2"},"abc",function(data){ console.log("get result:"+JSON.stringify(data));},function(e){ console.log("exception:"+e);});