签名在Alljoyn框架上获取错误? [英] signature get error on Alljoyn framework?

查看:82
本文介绍了签名在Alljoyn框架上获取错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android应用程序使用Alljoyn框架,并且遇到了一些问题

i'm working Android App use Alljoyn framework and i have some prolem

我有一个自定义对象

public class Package implements BusObject {


    public static enum DataSendType {
        TEXT,IMAGE
    }

    public static enum PackageStatus {
        NONE, SENDING, DONE
    }

    @Signature("s")
    private String m_id;
    @Signature("a")
    private ArrayList<DataPackage> m_listPackage;
    @Signature("r")
    private PackageStatus m_status;
    @Signature("r")
    private DataSendType m_type;
    @Signature("s")
    private String m_packageName;
}

和界面

@BusInterface (name="xxxx.simpleinterface")
public interface SimpleInterface {

    @BusSignal (name="Chat", signature="o")
    public void Chat(Package message) throws BusException;
}

但我收到此错误无法将类打包为 o 使用聊天(打包)时。

but i get this error cannot marshal class Package into 'o' when use Chat(Package)..

请帮助我,因为我无法在2周内解决此错误。

pls help me, because i can't get this error out for 2 weeks.

对不起,因为我的英语太糟糕了:)

sorry because my English is too bad :)

推荐答案

看着你的代码看起来像您要发送的是结构体,结构体的签名应为 r 或括号内的实际签名为。例如,对于包裹,签名应为(sayiis)

looking at your code it looks like what you are trying to send is a struct the signature for a struct should be "r" or the actual signature surrounded by parenthesizes ( and ). i.e. for Package the signature would be "(sayiis)"


  • 使用AllJoyn,您可以发送数组,但不能发送 ArrayList ,并且必须指定数组中的数据类型。

  • 由于您的 DataSendType 指定了 TEXT IMAGE 我假设您要发送一个字节数组。

  • 我没有添加签名的大多数项目,因为AllJoyn可以使用反射来找出签名。但是,AllJoyn不知道枚举将作为整数传输,因此我必须为枚举指定签名。

  • 包不必实现BusObject。在代码中,当您实现 SimpleInterface 时,应扩展 SimpleInterface 和`BusObject'

  • 使用AllJoyn发送的任何内容都应该是公共的,以便接口可以读取成员变量。

  • With AllJoyn you can send an array but not an ArrayList and you must specify the type of data that is in the array.
  • Since your DataSendType specified TEXT or IMAGE I made the assumption that you want to send an array of bytes.
  • Most of the items I did not add a signature to because AllJoyn can figure out the signature using reflection. AllJoyn however does not know that enums will be transmitted as integers so I did have to specify the signature for the enums.
  • Package did not have to implement BusObject. In your code when you implement your SimpleInterface that should extend the SimpleInterface and `BusObject'
  • Anything sent using AllJoyn should be public so the interface can read the member variables.

public class Package {
    public static enum DataSendType{
        TEXT,
        IMAGE
    }

    public static enum PackageStatus {
        NONE,
        SENDING,
        DONE
    }

    @Position(0)
    public String m_id;
    @Position(1)
    public byte[] m_listPackage;
    @Position(2)
    @Signature("i")
    public PackageStatus m_status;
    @Position(3)
    @Signature("i")
    public DataSendType m_type;
    @Position(4)
    public String m_packageName;
}


签名应为 r 来构造签名 o 表示对象路径。这是一个AllJoyn对象路径,这意味着它只是带有路径数据的字符串。

for the interface the signature should be "r" for struct the signature "o" means object path. This is an AllJoyn object path which means it just a string with path data.

@BusInterface (name="xxxx.simpleinterface")
public interface SimpleInterface {

    @BusSignal (name="Chat", signature="r")
    public void Chat(Package message) throws BusException;
}

如果您确实需要使用ArrayList,请先将ArrayList转换为实际的数组发送聊天信号。

If you really need to use an ArrayList convert the ArrayList to an actual array before sending the Chat signal.

这篇关于签名在Alljoyn框架上获取错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆