In c++ server I serialize a capn object by getSegmentsForOutput method ,in java client how can I read the capn object

29 views
Skip to first unread message

张钊

unread,
Nov 12, 2019, 11:59:44 AM11/12/19
to capn...@googlegroups.com

Hi David Renshaw && Kenton Varda

  

    In C++ server I do like this 

    capnp::MallocMessageBuilder message;

    Info::Builder info = message.initRoot<Info>();

    info.setId(123);

    info.Titile("this is how to use capn");

  

    


    kj::ArrayPtr<const kj::ArrayPtr<const capnp::word>> segments = message.getSegmentsForOutput();



    and then convert segments[0] to char* and send it by rpc_call to java client



    In java client ,I read capn object like this :

    


    ByteString object_bytes = rpc_response.getResponseData();

    MessageReader message = org.capnproto.Serialize.read(object_bytes.asReadOnlyByteBuffer());,

    Info.Reader adInfo = message.getRoot(Info.factory);



C++ server and Java Client communication by rpc_call


but happen Error like this:


Exception in thread "main" java.lang.IllegalArgumentException

at java.nio.Buffer.limit(Buffer.java:275)

at org.capnproto.Serialize.read(Serialize.java:140)

at org.capnproto.Serialize.read(Serialize.java:111)


How Can I do , This problem has been bothering me for many days. thanks


whutbd




 

Reply all
Reply to author
Forward
0 new messages