AllJoyn-跨平台方法调用返回值为自定义类型

9 篇文章 1 订阅
9 篇文章 0 订阅
AllJoyn-跨平台方法调用返回值为自定义类型
         service端代码:
    public class MyStruct{
        @Position(0)
        public String fileName;
        @Position(1)
        public int isoValue;
        @Position(2)
        public boolean dateTaken;
    }

    @BusMethod(replySignature = "sib")
    MyStruct catStruct(String a,String b)throws BusException;
        方法实现:
        public MyStruct catStruct(String a,String b){
            MyStruct temp=new MyStruct();
            temp.fileName=a;
            temp.isoValue=a.length();
            temp.dateTaken=a.length()>b.length()?true:false;
            return temp;
        }
        client端:
        增加的接口方法:
	testIntf->AddMethod("catStruct", "ss", "sib", "inStr1,inStr2,outStrStruct", 0);
        调用:
	QStatus status = remoteObj.MethodCall(INTERFACE_NAME, "catStruct", inputs, 2, reply, 5000);
        解析自定义类型的数据:
	//struct
	struct {
		char* str1;
		int aInt;
		bool bBool;
	}myStruct;
	printf("%s\n",reply->GetSignature());
	reply->GetArgs("sib", &myStruct.str1, &myStruct.aInt, &myStruct.bBool);
	printf("%s-%d-%s\n", myStruct.str1, myStruct.aInt, myStruct.bBool == true ? "true" : "false");
        调用实现结果截图:






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值