0

Signal handler is called multiple times

asked 2014-11-07 14:56:16 -0700

snowmagic gravatar image

Alljoyn 14.06 x86

I wrote a Alljoyn producer A which implements an interface that contains a signal member. When I start up my consumer app, it will enumerate all the bus objects, introspect them and add signal handle for every alljoyn event.

The problem I have is that when I start multiple producer A, then start consumer, when one producer sends a signal, the consumer's signal handler is called multiple times.

By looking at the Alljoyn code, when registering a signal handler, the bus object doesn't need to specify which is the target object it wants to receive from, and it uses a signal table which is a unordered_multimap that allows dup keys to track signal handlers. In my case, if I start n producers, n signal handlers will be registered and added to the table for the same signal.

I didn't find any API that I can query if any handler has been registered or not before I add it, other than tracking all the registered signal handler on my own application, is there any other way to solve this problem?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-11-07 15:55:11 -0700

bspencer gravatar image

There is no API to check if a signal handler has been registered. One thing you can do is if the Signal Handler is intended to receive a Sessionless Signal from a specific Producer, you can look at the MessageContext and decide if the Signal was from the device/application you are expecting.

The other option would be to have a global structure that contains the interface and member name along with the signal handler callback. Then when you encounter another producer element you are interested that you already have a handler for, ignore it and move on.

edit flag offensive delete publish link more

Comments

bspencer, thanks for your reply, I will use a global set to track registered signals, but I feel this is more like a work around, because I will need to maintain another structure and lock which already exists in signal table. Don't you think it's reasonable for BusAttachment class to have an API like RegisterSignalHandleIfNotExist? I think it's a common need for any apps that wants to add signal handler based on introspec result.

snowmagic ( 2014-11-10 14:18:00 -0700 )edit

Propose this change to the member of the AllSeen alliance (email allseen-core@lists.allseenalliance.org).

bspencer ( 2014-11-11 12:52:36 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-11-07 14:56:16 -0700

Seen: 125 times

Last updated: Nov 07 '14