Download
(13Kb)
Download
Updated: 01-07-07 04:01 PM
Updated:01-07-07 04:01 PM
Created:unknown
Downloads:3,021
Favorites:5
MD5:

WhoLib

Version: 2.3.0
by: Malex [More]

This addon manages 'who' requests. It uses the 'who' popup to retrieve information about users in the background, storing the data in a cache.

Addons that implement their own 'who' system will clash with eachother and potentially clash with the user's interaction with the popup.

Using this addon in your mod will eliminate clashes with other addons and the user's interaction with the 'who' popup.

The API consists of a two methods:

Code:
--------------------------------------------------------------------------------
--
-- Method: WhoLib_GetUserInfo
--
-- Description: Retrieves user 'who' information either from the cache or
--	from the game.  This method can be called in 2 ways.  You can poll for data
--	or you can specify a callback that will be called if the data isn't 
--	immediately available.  If the callback method is used, a maxTimestamp
--	must also be specified.
--
-- Parameters:
--
--	userName - [in] The user name to query
--
--	maxTimestamp - [in, optional] Used to specify the tolerated age of the data
--		in seconds.  The default value is 1800 (30 min).  Any cached data that is
--		older than this value will be discarded and fresh data will be retrieved.
--		If you need the latest data, specify 0 here to clear the cached value, but 
--		don't call it repeatedly with 0, only once, otherwise no data will ever be
--		returned.
--
--	callback - [in, optional] An optional parameter that can be used to be notified 
--		of a completed query instead of polling.  If this parameter is specified
--		and WhoLib_GetUserInfo returns isValid=false, it means that the supplied
--		callback function will be called when the query is satisfied.
--
--		This function should be of the following form, where "data" is a table of 
--		user info values normally returned by WhoLib_GetUserInfo with the inclusion
--		of the "Name" value and the exlusion of the "timestamp" value.
--		
--		local function MyGetUserInfoCallback(data, context)
--
--			-- Use "context" to determine the pending request that the "data"
--			-- belongs to
--			--
--			
--			-- Access the user info through the "data" parameter
--			--
--			if(data ~= nil) then
--
--				Print(data.Name);
--				Print(data.GuildName);
--				Print(data.Level);
--				Print(data.Race);
--				Print(data.Class);
--				Print(data.Zone);
--
--			else
--
--				Print("User not found");
--
--			end
--
--		end
--
--		Note:  If WhoLib_GetUserInfo returns isValid=true, the callback will
--			not be called.
--
--	context - [in, optional] An optional parameter used in conjunction with the
--		callback parameter.  This value will be passed back to the caller through
--		the callback function.  If you have multiple outstanding requests, you 
--		might want to use the context parameter to store the userName, so you know
--		what data you are getting when the callback is called.  If this parameter 
--		isn't specified, the callback function will receive a nil value as it's
--		"context" parameter.
--
-- Returns:
--
--	isValid - true/false indicating whether the data is available for the userName.
--		If true, it means that the return values are valid.  False means that data
--		is still pending from the server and the method can be polled until the
--		value is true.  If the function returns false and a callback parameter was
--		specified, the callback will be called when the query is satisfied.
--
--	guildName - The guild name of the character if a member or else an empty string
--
--	level - The level of the character
--
--	race - The race of the character
--
--	class - The class of the character
--
--	zone - The zone of the character at the time of the query
--
--	timestamp - The time when the cache entry was last updated.  This value is 
--		the number of seconds since Jan 1 1970.  Use "SecondsToTime" function to
--		convert this to hours/minutes friendly string, or do a time() - timestamp
--		to figure out how old the data is.
--
--------------------------------------------------------------------------------
function WhoLib_GetUserInfo(...)







--------------------------------------------------------------------------------
--
-- Method: WhoLib_Query
--
-- Description: Used to query for who information using a filter
--
-- Parameters:
--
--	filter - [in] This filter string will be directly passed to the SendWho()
--		method and determines the results returned
--
--	callback - [in, optional] An optional parameter that can be used to be notified 
--		of a completed query instead of polling.  If this parameter is specified
--		and WhoLib_Query returns isValid=false, it means that the supplied
--		callback function will be called when the query is satisfied.
--
--		This function should be of the following form, where "data" is a table of 
--		tables containing query results matching the supplied query filter.  Each
--		entry contains the user info for a single user, similar to the return values
--		of WhoLib_GetUserInfo with the inclusion of the "Name" value and the exclusion
--		of the "timestamp" value.
--		
--		local function MyQueryCallback(data, context)
--
--			-- Use "context" to determine the pending request that the "data"
--			-- belongs to
--			--
--			
-- 			-- Loop over all the results
--			--
--			if(data ~= nil) then
--
--				for index, item in ipairs(data) do
--
--					Print(item.Name);
--					Print(item.GuildName);
--					Print(item.Level);
--					Print(item.Race);
--					Print(item.Class);
--					Print(item.Zone);
--
--				end
--
--			else
--
--				Print("No results found");
--
--			end
--
--		end
--
--		Note:  If WhoLib_Query returns isValid=true, the callback will not be 
--			called.
--
--	context - [in, optional] An optional parameter used in conjunction with the
--		callback parameter.  This value will be passed back to the caller through
--		the callback function.  If you have multiple outstanding requests, you 
--		might want to use the context parameter to store the userName, so you know
--		what data you are getting when the callback is called.  If this parameter 
--		isn't specified, the callback function will receive a nil value as it's
--		"context" parameter.
--
-- Returns:
--
--	isValid - true/false indicating whether the data is available for the query.
--		If true, it means that the return values are valid.  False means that data
--		is still pending from the server and the method can be polled until the
--		value is true.  If the function returns false and a callback parameter was
--		specified, the callback will be called when the query is satisfied.
--
-- 	data - A list of data representing the results of the query.  Each value in
--		the list is identical to the data returned from WhoLib_GetUserInfo with the
--		inclusion of the "Name" field, and the exclusion of the "timestamp".
--
--		For example:
--
--			if(data ~= nil) then
--
--				Print("ResultsCount: " .. getn(data));
--
--				for index, item in ipairs(data) do
--
--						Print("Name: " .. item.Name);
--						Print(GuildName: " .. item.GuildName);
--						etc...			
--
--				end
--
--			else
--
--				Print("No results found");
--
--			end
--
-- Remarks:
--
--	Results from this function are not cached.  Once the function returns true,
--	a future call to the function will initiate another query.  Store the returned
--	data set in your addon and use it from there.
--
--------------------------------------------------------------------------------
function WhoLib_Query(...)

Post A Reply Comment Options
Unread 11-20-07, 10:51 PM  
Hevanus
A Deviate Faerie Dragon
 
Hevanus's Avatar

Forum posts: 15
File comments: 199
Uploads: 0
Generates an error whenever I zone with people in the queue.

Also, when I do a /chatlist to see what channels I'm in or who is in a channel, WhoLib eats the results and I never get to see them
Report comment to moderator  
Reply With Quote
Unread 05-12-07, 02:28 PM  
Hevanus
A Deviate Faerie Dragon
 
Hevanus's Avatar

Forum posts: 15
File comments: 199
Uploads: 0
SpamSentry

I'm not sure which addon is at fault, but WhoLib r35203 from the WoWAce SVN will not run disembedded with SpamSentry r35234.

It runs fine embedded, but I shouldn't have to do it that way.
Report comment to moderator  
Reply With Quote
Unread 12-28-06, 01:45 PM  
Malex
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 8
Uploads: 3
Please post comments, feedback, and bug reports here.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: