Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIMessageListenerManager

This article needs a technical review. How you can help.

This interface enables clients to listen for messages sent using the nsIMessageBroadcaster, nsIMessageSender, or nsISyncMessageSender interfaces.
1.0
48
Introduced
Gecko 17
Inherits from: nsISupports Last changed in Gecko 41 (Firefox 41 / Thunderbird 41 / SeaMonkey 2.38)

Implemented by: @mozilla.org/globalmessagemanager;1. To access this service, use:

var globalMM = Components.classes["@mozilla.org/globalmessagemanager;1"]
               .getService(Components.interfaces.nsIMessageListenerManager);

Method overview

void addMessageListener(in AString messageName,
                        in nsIMessageListener listener,
                        [optional] in boolean listenWhenClosed)
void removeMessageListener(in AString messageName,
                           in nsIMessageListener listener);
void addWeakMessageListener(in AString messageName,
                            in nsIMessageListener listener);
void removeWeakMessageListener(in AString messageName,
                               in nsIMessageListener listener);

Methods

addMessageListener()

Register listener to receive messageName.  All listener callbacks for a particular message are invoked when that message is received. The message manager holds a strong reference to listener. If the same listener registers twice for the same message, the second registration is ignored.

void addMessageListener(in AString messageName,
                        in nsIMessageListener listener,
                        [optional] in boolean listenWhenClosed);

Parameters

messageName
A string indicating the name of the message to listen for.
listener
An nsIMessageListener to invoke when a message is received. See nsIMessageListener for details of the message syntax.
listenWhenClosed
Specify true to receive messages during the short period after a frame has been removed from the DOM and before its frame script has finished unloading; this is false by default. This parameter only has an effect for frame message managers in the main process. An alternative method to listen for death of frame script is to use a message-manager-disconnect  observer; see Observer Notifications :: Message Manager.

removeMessageListener()

Undo an addMessageListener() call; that is, calling this causes listener to stop being invoked when the specified message is received.

void removeMessageListener(in AString messageName,
                           in nsIMessageListener listener);

removeMessageListener() does not remove a message listener added via addWeakMessageListener(); use removeWeakMessageListener() for that.

Parameters

messageName
The name of the message whose listener is to be removed.
listener
An nsIMessageListener representing the listener to remove.

addWeakMessageListener()

This is just like addMessageListener(), except that the message manager holds a weak reference to listener.

void addWeakMessageListener(in AString messageName,
                            in nsIMessageListener listener);

If you have two weak message listeners for the same message, they may be called in any order.

Parameters

messageName
A string indicating the name of the message to listen for.
listener
An nsIMessageListener to invoke when a message is received. See nsIMessageListener for details of the message syntax.

removeWeakMessageListener()

Undo an addWeakMessageListener() call. That is, calling this causes the listener to no longer be invoked when messageName is received.

void removeWeakMessageListener(in AString messageName,
                               in nsIMessageListener listener);

removeWeakMessageListener() does not remove a message listener added via addMessageListener(); use removeMessageListener() for that.

Parameters

messageName
The name of the message whose listener is to be removed.
listener
An nsIMessageListener representing the listener to remove.

 

Document Tags and Contributors

 Contributors to this page: Wladimir_Palant, Sheppy, Noitidart, wbamberg
 Last updated by: Wladimir_Palant,