Framescripts, message from one Servics.mm to another

I have two addons. (well actually its one addon but the first one is the one being uninstalled and second one is the one being upgraded).

To make things simple, lets say its two different addons.

Addon 1 has registered a listener like this:

 Services.mm.addMessageListener('abc', fsComServer.clientMessageListener);

I now want to send a message to this guy from addon 2 or the scratchpad.

From scratchpad I tried:

 Services.cpmm.sendAsyncMessage('abc', {aTopic:'hi'});

But its not triggering addon 1 listener, does anyone know whats up? Notice I used cpmm from scratchpad. I also tried Services.mm.broadcastAsyncMessage but that obviously didn’t work as that broadcasts to listeners added within framescripts (Im guessing the Services.cpmm.addMessageListener).

Detail on reason i need this:
There is a race condition even though MDN says there is not. MDN says:

SOURCE

  • your add-on is disabled for an upgrade
  • your add-on broadcasts “disable” to your frame scripts
  • your add-on is upgraded, and the new code loads new frame scripts
    *the new frame scripts receive the “disable” message, and stop working

When I boradcast “disable” to the frame scripts, the disable procedure does something, for example it sets the border of the body to 0. The frame script on load sets border of the body to 10. So now when disable is broadcast to the frame scripts it doesnt wait for the disable procedure to complete. So immeidately after broadCast, the upgraded addon installs and it puts in its new frame script which sets border to 10. This happens before the unload procedure of the old version, so the new script sets it to 10, and the old framescript disable proc completes, setting it to 0. Very weird but it happens.

Silly/obvious question: have you tested the message listener from within your add-on code to make sure it’s properly added?

Thats a great question! Thanks jorge, yes it works when i send the message from a child script :frowning: