- Home
- Downloads
-
Addons & Mods
Featured
World of Warcraft
4,841 Addons
-
Popular Downloads
- Top World of Warcraft Addons
- Top Rift Addons
- Top Skyrim Mods
- Top Minecraft Server Mods
- Top Terraria Maps
- Top Starcraft II Maps
- Top Runes of Magic Addons
- Top Warhammer Online Addons
- Top Age of Conan Addons
-
- Curse Client
- Premium
- News
- Giveaways
- Forums
WhoLib
- 0 Likes
- World of Warcraft
- 43,285 Downloads
- Supports: 4.2
- 3 Average Daily Downloads
- Created 7/22/2008 11:45:47 AM
- Updated 6/28/2011 2:21:03 AM
- 33 Favorites
- Project Site
- License: MIT License
- Release Type: Release
- Newest File: 2.0.122
About WhoLib
Welcome to LibWho-2.0!
This documentation is for developers, it you're a user: just don't care.
- An Interface for a information's about an user
- Better event for who's
- Queuing of /who and SendWho()
- A much better who interface, with guarantee to be executed & callback
This version is 2.0, please do not run them together with 1.0 or other who libraries.
Usage
There are two ways of using WhoLib: embedding into an object or using the library directly
Embedded
-- at the beginning of your addon
LibStub:GetLibaray('LibWho-2.0'):Embed(self)
-- call a function within an method:
function mod:xxx(...)
self:UserInfo(...)
end
External
-- at the beginning of your addon
local wholib = LibStub:GetLibrary('LibWho-2.0'):Library()
-- call a function:
wholib:UserInfo(...)
Remarks
The examples in this documentation uses the embedded version, but it should be easy to adopt them to external.
API Documentation
lib:Embed(handler)
Args
- handler
- table - embed the public functions/constants in the object specified by handler
Returns
- nil
Example
LibStub:GetLibrary('LibWho-2.0'):Embed(self)
lib:Library()
Returns
- table - the library
Example
LibStub:GetLibrary('LibWho-2.0'):Library()
:UserInfo(name [, opts])
Args
- name
- string - the exact name of an player
- opts
- optional, table - options
- opts.queue
- optional, number - queue of this query (see below) - .WHOLIB_QUEUE_QUIET (default) or .WHOLIB_QUEUE_SCANNING
- opts.timeout
- optional, number - if the the result is cached, and not older than opts.timeout minutes the cache will be returned, negative value: always use cache (if available), otherwise: send a who query, default: 5 (minutes)
- opts.callback, opts.handler
- optional, callback - see "Callback info" below
- opts.flags
- optional, number - one of more flags or'ed together, see Flags (bit.bor(flag1, flag2 [, flag3 [, ...]]))
Returns
- nil
- if there was no appropriate cache
- false
- see Flags: WHOLIB_FLAG_ALWAYS_CALLBACK
- user, time
- for cached results
- user
- table - the user's information's
- user.Name
- string - name of the player
- user.Online
- true if online, false if offline, nil if unknown (more results than could be displayed)
- if Online is not true than all following entries will be from the last successful call, or nil
- user.Guild
- string - guild or ''
- user.Class
- string - class
- user.Race
- string - race
- user.Level
- string - level
- user.Zone
- string - zone
- time
- number - the minutes how old the data was
Remarks
If you're only interested in this feature, then you don't have to read about :Who() and WHOLIB_QUERY_RESULT.
Do not use .WHOLIB_FLAG_ALWAYS_CALLBACK when scanning a list over and over again, do a 5 sec pause after a
cached return, cause you may have a short list and a cache time so high that all entries may be cached
and in that case this function DO generate an almost infinite loop!
Callback
When a callback function is given and the function didn't returned immediately then the callback will be raised when they're a result. The callback function will receive the same arguments as :UserInfo() would return.
Flags
- .WHOLIB_FLAG_ALWAYS_CALLBACK
- if :UserInfo() would return the cached data, raise the callback immediately with that data instead returning and then return false
Example
-- long version
local user, time = self:UserInfo(friendsname, { callback = 'UserDataReturned' } )
if user then
-- the data was immediately available
self:UserDataReturned(user, time)
else
-- nothing
-- we will be called when the data is available
end
-- short version
self:UserData(friendsname, { callback = 'UserDataReturned', flags = self.WHOLIB_FLAG_ALWAYS_CALLBACK } )
-- callback function
function mod:UserDataReturned(user, time)
local state
if user.Online == true then
state = 'Online'
elseif user.Online == false then
state = 'Offline'
else
-- user.Online is nil
state = 'Unknown'
end
DEFAULT_CHAT_FRAME:AddMessage(user.Name .. ' is ' .. state)
end
:CachedUserInfo(name)
Args
- name
- string - the exact name of an player
Returnes
- nil
- if there was no appropriate cache
- user, time
- for cached results
- identical to :UserInfo()
:RegisterCallback(event, callback [,handler])
Args
- event
- string - the event you are want to be registered for
- callback, handler
- callback - see "Callback info" below
Returns
- nil
Example
see "Events" below
:Who(query [ , opts])
Args
- query
- string - the search string
- opts
- optional, table - options
- opts.queue
- optional, number - queue of this query (see below) - .WHOLIB_QUEUE_QUIET (default) or .WHOLIB_QUEUE_USER or .WHOLIB_QUEUE_SCANNING
- opts.callback, opts.handler
- optional, callback - see "Callback info" below
Returns
- nil
Remarks
This is an event registration via CallbackHandler-1.0
Everything except query will be ignored when the queue is .WHOLIB_QUEUE_USER.
If you've already registered WHOLIB_QUERY_RESULT then you may be don't need a callback.
Callback
When a callback function is given then the callback will be raised after the query is executed. The callback function will receive the same arguments as the event :WHOLIB_QUERY_RESULT has.
Example
self:Who({query = 'n-' .. friendsname, queue = self.WHOLIB_QUERY_QUIET, callback = 'DisplayPlayers'})
-- self:DisplayPlayers is in the WHOLIB_QUERY_RESULT example below
Remarks
If you're only interested in the information of one player, use :UserInfo() instead. (You can set opts.timeout to 0 if you don't accept cached data.)
Constants
.WHOLIB_QUEUE_USER
.WHOLIB_QUEUE_QUIET
.WHOLIB_QUEUE_SCANNING
.WHOLIB_FLAG_ALWAYS_CALLBACK
Callback info
Some WhoLib functions accepts its own form of callbacks, or callbacks via CallbackHandler, you have always two ways using them.
Using a function
- callback
- function - just point to the function, which should be called
- handler
- nil - must be nil
Example 1
local function eventmanager(event, a1, a2, ...)
-- has no 'self'
end
wholib:RegisterCallback('WHOLIB_QUERY_RESULT', eventmanager)
Example 2
function mod.eventmanager(event, a1, a2, ...)
-- has no 'self'
end
wholib:RegisterCallback('WHOLIB_QUERY_RESULT', mod.eventmanager)
Using a method
- callback
- string - the name of the method, which should be called
- handler
- table - the object on which the method should be called, if nil the calling object is used
Example
function mod:eventmanager(event, a1, a2, ...)
-- has 'self'
end
mod:RegisterCallback('WHOLIB_QUERY_RESULT', 'eventmanager')
-- is equivalent to
wholib:RegisterCallback('WHOLIB_QUERY_RESULT', 'eventmanager', self)
Events
Event: WHOLIB_QUERY_RESULT - query, results, complete, name
Args
- query
- string - search string
- results
- table - table of results
- results[i].Name
- string - name of the player
- results[i].Online
- true if online, false if offline, nil if unknown (more results than could be displayed)
- results[i].Guild
- string - guild or ''
- results[i].Class
- string - class
- results[i].Race
- string - race
- results[i].Level
- string - level
- results[i].Zone
- string - zone
- complete
- boolean - shows whether all results could be returned (true) or not (false), if not, do a more specific query
- name
- string - if the query was initiated by a :UserInfo() call, then this is the player name of the :UserInfo() call, otherwise nil
Remarks
All these fields are returned when any one call "/who" "SendWho()" or :Who(), even when the results are displayed in the chat.
Example
function mod:OnEnable()
...
self:RegisterCallback('WHOLIB_QUERY_RESULT', 'DisplayPlayers')
...
end
function mod:DisplayPlayers(query, results, complete)
if not complete then
DEFAULT_CHAT_FRAME:AddMessage('There were more Players than here shown!')
end
for _,result in pairs(results) do
DEFAULT_CHAT_FRAME:AddMessage('Player ' .. result.Name .. ' is currently in ' .. result.Zone)
end
end
Queues
WHOLIB_QUEUE_USER
Used on user queries (e.g. "/who", SocialFrame's Who)
Will display the results in chat if only some, or in who-frame if more.
WHOLIB_QUEUE_QUIET
Should be standard queue for addon queries, which aren't for scanning, and do not result in a user action: use .WHOLIB_QUEUE_USER.
Will neither show chat messages nor who-frame.
Will be slowly queried while the WhoFrame is open. (TODO)
WHOLIB_QUEUE_SCANNING
Use for scanning.
Will neither show chat messages nor who-frame.
Will not be queried while the WhoFrame is open. (TODO)
Remarks
At first the .WHOLIB_QUEUE_USER queries will be executed, then the .WHOLIB_QUEUE_QUIET and at last the .WHOLIB_QUEUE_SCANNING.
Debug
When debugging is enabled then the chat will be filled with added/returned entries, one for each query.
21:01:40 WhoLib: [3] added "n-Lager", queues=0, 0, 1 21:01:40 WhoLib: [3] returned "n-Lager", total=0, queues=0, 0, 0
The [3] means Queue 3 = WHOLIB_QUEUE_SCANNING, each query will at first be "added" and later "returned",
on returned queries the total number of entries will also be printed.
The "queues=0, 0, 1" means that 0 queries are in the .WHOLIB_QUEUE_USER queue,
0 in .WHOLIB_QUEUE_QUIET, and 1 (the added one) in .WHOLIB_QUEUE_SCANNING.
For :UserInfo() even more entries will be printed.
:SetWhoLibDebug(state)
Args
- state
- boolean - Enables or disables the debugging
Returns
- nil
/wholibdebug
Toggles the debugging.
TODO
- localization
- maybe better English texts
- cleaning code?
- see WHOLIB_QUEUE_QUIET's TODO
Remarks
If someone wants to help me, just drop a note - or do it!
ALeX Kazik - alx@kazik.de
------------------------------------------------------------------------
r122 | sylvanaar | 2011-06-28 07:19:27 +0000 (Tue, 28 Jun 2011) | 1 line
Changed paths:
A /tags/2.0.122 (from /trunk:121)
Tagging as 2.0.122
------------------------------------------------------------------------
r121 | sylvanaar | 2011-06-28 07:06:09 +0000 (Tue, 28 Jun 2011) | 1 line
Changed paths:
M /trunk/LibWho-2.0.toc
TOC 40200
------------------------------------------------------------------------
| File Name | Release Type | Game Version | Downloads | Date |
|---|---|---|---|---|
| 2.0.122 | Release | 4.2 | 792 | 6/28/2011 2:21:03 AM |
| 2.0.122-nolib | Release | 4.2 | 236 | 6/28/2011 2:21:03 AM |
| 2.0.120 | Release | 4.0.6 | 992 | 4/26/2011 7:19:07 AM |
| 2.0.120-nolib | Release | 4.0.6 | 485 | 4/26/2011 7:19:07 AM |
| 2.0.118 | Release | 4.0.3a | 1,657 | 12/14/2010 6:10:50 PM |
| 2.0.118-nolib | Release | 4.0.3a | 838 | 12/14/2010 6:10:50 PM |
| 2.0.116 | Release | 4.0.1 | - | 10/20/2010 5:25:39 PM |
| 2.0.116-nolib | Release | 4.0.1 | - | 10/20/2010 5:25:38 PM |
| 2.0.113 | Release | 3.3.0 | 2 | 2/22/2010 4:03:19 PM |
| 2.0.113-nolib | Release | 3.3.0 | - | 2/22/2010 4:03:16 PM |
| 2.0.110 | Release | 3.3.0 | - | 12/13/2009 8:21:10 AM |
| 2.0.110-nolib | Release | 3.3.0 | - | 12/13/2009 8:21:06 AM |
| 2.0.107 | Release | 3.2.0 | - | 10/18/2009 9:40:54 PM |
| 2.0.107-nolib | Release | 3.2.0 | - | 10/18/2009 9:40:51 PM |
| 2.0.104 | Release | 3.2.0 | - | 9/28/2009 2:06:48 PM |
| 2.0.104-nolib | Release | 3.2.0 | - | 9/28/2009 2:06:45 PM |
| 2.0.102 | Release | 3.2.0 | 2 | 8/24/2009 4:51:36 PM |
| 2.0.102-nolib | Release | 3.2.0 | - | 8/24/2009 4:51:33 PM |
| 2.0.95 | Release | 3.2.0 | - | 8/4/2009 4:10:16 PM |
| 2.0.95-nolib | Release | 3.2.0 | - | 8/4/2009 4:10:12 PM |
| 2.0.88 | Release | 3.1.0 | - | 7/30/2009 1:07:36 AM |
| 2.0.88-nolib | Release | 3.1.0 | - | 7/30/2009 1:07:33 AM |
| 2.0.86 | Release | 3.1.0 | - | 7/24/2009 10:55:37 AM |
| 2.0.86-nolib | Release | 3.1.0 | - | 7/24/2009 10:55:34 AM |
| 2.1b1 | Beta | 3.1.0 | - | 7/15/2009 10:34:09 PM |
| 2.1b1-nolib | Beta | 3.1.0 | - | 7/15/2009 10:34:06 PM |
| 2.0.2 | Release | 3.1.0 | - | 4/14/2009 7:40:22 AM |
| 2.0.2-nolib | Release | 3.1.0 | - | 4/14/2009 7:40:19 AM |
| 2.0.1 | Release | 3.0.9 | - | 4/8/2009 6:51:04 PM |
| 2.0.1-nolib | Release | 3.0.9 | - | 4/8/2009 6:51:01 PM |
| 2.0 | Release | 3.0.3 | - | 11/18/2008 1:04:11 PM |
| b2 | Beta | 3.0.3 | - | 11/10/2008 11:28:21 PM |
| 2.0b1 | Beta | 3.0.3 | - | 11/10/2008 11:08:09 PM |
| 1.0 (Pre-WoTLK) | Beta | 2.4.3 | - | 11/10/2008 7:34:15 PM |
| 1.0 (Pre-WoTLK)-nolib | Beta | 2.4.3 | - | 11/10/2008 7:34:14 PM |
| WhoLib-r78925.1 | Beta | 2.4.3 | 1 | 9/29/2008 1:37:38 AM |
| WhoLib-r78925-nolib | Beta | 2.4.3 | - | 7/22/2008 8:24:10 AM |
| WhoLib-r78925 | Beta | 2.4.3 | 1 | 7/22/2008 8:24:10 AM |
| WhoLib-r78828 | Beta | 2.3.3 | - | 7/20/2008 11:31:05 PM |
| WhoLib-r78828-nolib | Beta | 2.3.3 | - | 7/20/2008 11:31:05 PM |
| WhoLib-r78220-nolib | Beta | 2.3.3 | - | 7/10/2008 8:13:42 PM |
| WhoLib-r78220 | Beta | 2.3.3 | - | 7/10/2008 8:13:42 PM |
| WhoLib-r73861 | Beta | 2.3.3 | - | 5/14/2008 11:08:51 AM |
| WhoLib-r73861-nolib | Beta | 2.3.3 | - | 5/14/2008 11:08:51 AM |
| WhoLib-r73809-nolib | Beta | 2.3.3 | - | 5/14/2008 1:05:03 AM |
| WhoLib-r73809 | Beta | 2.3.3 | 1 | 5/14/2008 1:05:03 AM |
| WhoLib-r64386.1 | Beta | 2.3.3 | - | 3/26/2008 4:23:12 AM |
| WhoLib-r64386-nolib | Beta | 2.3.3 | - | 3/12/2008 10:43:38 AM |
| WhoLib-r64386 | Beta | 2.3.3 | 1 | 3/12/2008 10:43:38 AM |
| WhoLib-r62295.1 | Beta | 2.3.3 | - | 3/7/2008 4:06:35 AM |