Thread Tools Display Modes
12-30-14, 01:57 AM   #1
BlueRaja
A Defias Bandit
Join Date: Dec 2014
Posts: 3
Is there a way to order event callbacks (by plugin)?

I'm extending a chat-filter plugin to work with several other chat-based plugins. The other plugins handle the "CHAT_MSG_CHANNEL" event, and return true, indicating they've handled the message and (I assume) stopping the event from bubbling to other plugins.

In order to filter these messages, I need to handle them before the other plugins. Is there some way of guaranteeing the order that events are passed to plugins?
  Reply With Quote
12-30-14, 06:25 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1) Chat filters are processed in the order registered. There's no way to tell WoW to load your addon before some other addon (without modifying the other addon to list your addon as an optional dependency). If you really need to run your filters first (though I'm not really sure why; if you have some other addon blocking messages, it's still going to block messages if its filter gets run after yours) then depending on the addon it may be possible to remove and re-add its filter (thus moving it to the end of the list) or you can take the nuclear approach and remove all other filters for the given event(s) and re-add them.

2) Returning true means the filter has blocked the message, and prevents any further processing for that message, including other filters.

3) Returning false or nil means the filter did not block the message, and filters continue to be run in order.

3b) If a filter returns any arguments in addition to false/nil it must return all of the event arguments that were passed into it (note that the first two arguments it receives are not event arguments and should not be returned) but it may modify them, and they replace the original event arguments. Additional filters are called with these new event arguments.

You can see how the default UI does this in FrameXML/ChatFrame.lua.

Finally, I assume you're talking about Trade Chat Cleaner since you just submitted some patches for it (thanks BTW) but I'm not really sure why you'd need it to run before other addons. Like I said, if you have some other addon blocking stuff, that stuff will still be blocked no matter what order the filters are run in.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-30-14, 10:59 AM   #3
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
What kind of goal do you have for your addon that you need to watch every chat message unfiltered? It's still possible, (using "Phanx's nuclear approach") but I guess It'd be nice if there was some kind of way to register for unfiltered events, similar to how combat logging events can be unfiltered (CLEU).
  Reply With Quote
12-30-14, 11:49 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by ravagernl View Post
It'd be nice if there was some kind of way to register for unfiltered events, similar to how combat logging events can be unfiltered (CLEU).
You can. Just register for the events directly instead of adding filters for them.

Also, the OP submitted this pull request which leads me to believe they're having some kind of compatibility issue with TradeForwarder. I haven't looked at the code of that addon yet, but after reading your post it occurs to me that the problem OP is trying to solve may be that TradeForwarder is using filters instead of normal event registrations and therefore isn't working with my addon which uses filters for their intended purpose of filtering messages. But, until OP clarifies, or I have time to look at the other addon's code, who knows.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 12-30-14 at 11:54 AM.
  Reply With Quote
12-30-14, 12:03 PM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Phanx View Post
[...] which leads me to believe they're having some kind of compatibility issue with TradeForwarder. I haven't looked at the code of that addon yet, but after reading your post it occurs to me that the problem OP is trying to solve may be that TradeForwarder is using filters instead of normal event registrations and therefore isn't working with my addon which uses filters for their intended purpose of filtering messages. But, until OP clarifies, or I have time to look at the other addon's code, who knows.
I see. I'm presuming TradeForwarder uses filters for outgoing messages because nobody wants to see their own echo's, or when in city, echo's from other users.

You can. Just register for the events directly instead of adding filters for them.
/selfpalm I can say that I'm glad to be off till the 5th. It's been a long week for me (am I spoiled?)

Last edited by ravagernl : 12-30-14 at 12:07 PM.
  Reply With Quote
12-30-14, 03:51 PM   #6
BlueRaja
A Defias Bandit
Join Date: Dec 2014
Posts: 3
TradeForwarder is a plugin that allows you to view Trade-Channel messages no matter where you are. It works by having people who are in town forward the trade-messages to a hidden channel. TradeForwarder then subscribes to that hidden channel, blocks all the messages from that channel from being seen, and parses/displays the messages manually.

So, the problem is that if TradeForwarder handles the messages before TradeChatCleaner, then TradeChatCleaner never gets a chance to filter them, and every trade messages is displayed. If TradeChatCleaner goes first, it can filter the ones I don't want to see before TradeForwarder sees them.

Last edited by BlueRaja : 12-30-14 at 03:54 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Is there a way to order event callbacks (by plugin)?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off