1.在服务器中定义methods:
Meteor.methods({
getApkMsg:function(_id){
console.log("Meteor.methods _id "+_id);
return FileRecords.findOne({_id:_id});//可以直接返回string
}
});
2.在client的调用 或者 在android程序中调用
var _id="ddsfsdfds";
Meteor.call('getApkMsg',_id,function(error,msg){
if(error){
console.log("getApkMsg "+ " error:"+error);
return;
}
console.log("getApkMsg "+ " msg:"+EJSON.stringify(msg));//msg是一个Object类型 用EJSON解析
});
在andoird中调用:
mMeteor = new Meteor(mUrl);
mMeteor.setCallback(this);
mMeteor.call("getApkMsg", new String[] {_id}, new ResultListener() {
@Override
public void onError(String arg0, String arg1, String arg2) {
Log.d(TAG, "getApkMsg arg0=" + arg0 + " |arg1=" + arg1
+ " |arg2=" + arg2);
}
@Override
public void onSuccess(String arg0) {
Log.d(TAG, "getApkMsg arg0=" + arg0);
}
});
|