0

Proper way of using BusSignals in CPP

asked 2014-05-21 03:48:01 -0700

yan.foto gravatar image

I have been using BusSignals in Java using SignalEmitter and properly annotated interfaces. According to the samples delivered with the source code, the C++ approach differs from that of Java. I just wanted to know If the following is the correct procedure if my client is not a signal handler and is only a signal emitter:

  1. Attach bus, start and connect.
  2. Register listener and discover apps providing signal handlers
  3. Create an Interface (à la alljoyn_core/samples/basic/basic_client.cc)
  4. Add desired method to it.
  5. Create a ProxyBusObject
  6. Get interface with the same name from the bus and add it to the proxy object
  7. Call method call on the proxy object

The aforementioned list seems way too complicated comparing to Java (Create SignalEmitter and retrieve interface by its class), which made me so unsure about its correctness.

I may have understood the procedure completely wrong. So any comments are really appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-05-21 10:46:43 -0700

bspencer gravatar image

Hi, The flow you have is incorrect. Please look at the sample: https://git.allseenalliance.org/cgit/core/alljoyn.git/tree/alljoyn_core/samples/basic/signal_service.cc

  1. Attach to the AllJoyn BusAttachment, start and connect.
  2. Create a BusObject (signals are sent from BusObjects)
  3. Create an InterfaceDescription that matches the same name and member names (use AddSignal for adding a signal)
  4. Register the BusObject with the AllJoyn BusAttachment
  5. Implement a method inside the class that extends BusObject that uses the Signal method. NOTE: You will need to be in a session and setup the listeners and calls to join a session if you are not using a sessionless Signal.

Following the code in the basic/signal_service.cc will give you what you need.

edit flag offensive delete publish link more

Comments

Could you also please elaborate why I use `AddSignal` to add the signal to the interface but use `GetMember` and not `GetSignal` to access my desired signal to use with `Signal` method?

yan.foto ( 2014-05-21 11:26:44 -0700 )edit

You first need to build the interface. When you build the interface via the AllJoyn API method calls you can use the shortcut method of `AddSignal`. When you wish to interact with the interface you need to use the `GetSignal` which will store that into a member object. To then interact and send a signal you supply the `BusObject::Signal` method with the `InterfaceDescriptionMember` which will allow the API call to verify and form the correct information along with the other supplied values to send out the signal.

bspencer ( 2014-05-21 11:45:07 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-05-21 03:48:01 -0700

Seen: 52 times

Last updated: May 21 '14