View Single Post
07-16-10, 11:14 AM   #2
toddimer
A Deviate Faerie Dragon
 
toddimer's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 18
A few of my concerns with the current implementation:

Ambiguity: Asynchronous Completion

Goal: let addons know when the inspect API is ready, busy, abandoned, or failed.

Current Challenge: Authors must resort to timeouts, when the API fails or is abandoned. documentation on the proper timeout values isn't readily available

Kudos to whoever made this call asynchronous. That lets the server merrily collect data on my inspect target, without locking my UI. Fabulous. That process isn't as transparent as I'd like, though.

The current workflow is something like (a) request data via NotifyInspect, (b) cache the name of the player locally, then (c) wait for an event from INSPECT_TALENT_READY. If INSPECT_TALENT_READY is received (d) do stuff, and call ClearInspectPlayer when finished.

As far as i can tell, INSPECT_TALENT_READY will fail to fire if: the inspect target is bogus; another NotifyInspect is sent while the old one is processing; the inspect target is (or moves) out of inspect range while processing; or the server gets too many requests within a ~10 second window. "Fail to return" really sucks, because it's an undetectable event. It's entirely possible the call would return after, say, 20 seconds, or 5...that information isn't publicly known. So an author has to code an arbitrary timeout

Note that other addons can mess with each other. Firing NotifyInspect while another addon is waiting for INSPECT_TALENT_READY will severely mess with them. You can detect this behavior by hooking NotifyInspect, INSPECT_TALENT_READY, and ClearInspectPlayer; it's generally bad etiquette to call NotifyInspect between when anyone else has called notify inspect, and when they call ClearInspectPlayer. There's nothing to enforce this though... an addon can very well call back-to-back inspect data for multiple players without clearing the inspect player, effectively hogging the API.

To Solve: A unique ID could be assigned/returned from NotifyInspect, which is attached to the relevant INSPECT_TALENT_READY event. Add notifications for INSPECT_FAILED and/or INSPECT_ABANDONED, either as new events, or as a return code in INSPECT_TALENT_READY. I'm sure there are other things that could work.