按例子已定义接口: struct User{ 1: string uid, 2: string uname, 3: bool usex, 4: i16 uage, } service UserService{ void add(1: User u), void adduname(1: string uname), User get(1: string uid), }
服务端代码片: var server=thrift.createServer(UserService, { add:function(user,callback){ console.log(“add stored:”,user.uname); users[user.uid]=user; console.log(users); callback();}, adduname:function(x,callback){ console.log(“adduname stored:”,x); callback(“MMMMM”);}, get:function(uid,callback){ console.log(“get received:”, uid); console.log(users[uid]); callback(); }
}
);
客户端代码片: client.adduname(“cccc”,function(err, res){ console.log(err); console.log(res); connection.end(); });
var cc=‘112’; client.get(cc,function(err, res){ // console.log(err); console.log(res); connection.end(); });
不知道为什么res老是收不到,请老鸟赐教~