0

dealing with signature and argument

asked 2015-04-13 00:10:14 -0800

anonymous user

Anonymous

updated 2015-04-13 00:29:09 -0800

Hi~ I am a beginner of Alljoyn SDK and trying to make an app with c++ in linux. (based on "Chat" example)

My problem is I don't know how to make "signature" and how to deal with arguments of MsgArg class.

I already checked some example online but i can not unstand it.

I need to make a Signal which have arguments ( string, INT32, INT32) and print them as arguments

so my code is (almost same with "Chat" example)

"###########################################################################"

InterfaceDescription* chatIntf = NULL;

chatIntf->AddSignal("Chat", "r(sii)", NULL, 0}; // <-- is this Signature right as a signature of struct?

chatIntf->Activate();

..

..

status = bus.RegisterSignalHandler(this, static_cast<messagereceiver::signalhandler>(&ChatObject::ChatSignalHandler), chatSignalMember NULL);</messagereceiver::signalhandler>

MsgArg chatArg("r(sii)", "hello", 1004, 1005);

// <-- is this right? i just want to send "hello" and 1004, 1005 as arguments

return Signal(NULL, s_sessionID, *chatSignalMember, &chatArg, 1, 0, flags);

//for print argument

void ChatSignalHandler(const InterfaceDescription::Member* member, const char* srcPath, Message& msg) {

printf(" string arg = %s \n", msg->GetArg(0)->v_string.str);

<-- is this right to print string argument "helllo"?

printf(" int arg1 = %s \n", msg->GetArg(1)->v_int32)

<-- is this right to print int argument "1004"?

printf(" int arg2 = %s \n", msg->GetArg(2)->v_int32);

<-- is this right to print int argument "1005"?

}

"###########################################################################"

i don't know how to use signature of struct with C++ code.

thanks in advenceenter code here

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-04-21 12:47:17 -0800

updated 2015-04-21 12:47:37 -0800

Use (sii) instead of r(sii) as the signature. The r is never sent over the air.

See http://dbus.freedesktop.org/doc/dbus-specification.html#idp94392448 for furthur details.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2015-04-13 00:10:14 -0800

Seen: 40 times

Last updated: Apr 21 '15