Mercurial > wow > askmrrobot
comparison Libs/AceComm-3.0/AceComm-3.0.lua @ 124:e31b02b24488
Updated for 8.0 pre-patch and BfA.
| author | yellowfive | 
|---|---|
| date | Tue, 17 Jul 2018 09:57:39 -0700 | 
| parents | 01b63b8ed811 | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 123:7a6364917f86 | 124:e31b02b24488 | 
|---|---|
| 7 -- and can be accessed directly, without having to explicitly call AceComm itself.\\ | 7 -- and can be accessed directly, without having to explicitly call AceComm itself.\\ | 
| 8 -- It is recommended to embed AceComm, otherwise you'll have to specify a custom `self` on all calls you | 8 -- It is recommended to embed AceComm, otherwise you'll have to specify a custom `self` on all calls you | 
| 9 -- make into AceComm. | 9 -- make into AceComm. | 
| 10 -- @class file | 10 -- @class file | 
| 11 -- @name AceComm-3.0 | 11 -- @name AceComm-3.0 | 
| 12 -- @release $Id: AceComm-3.0.lua 1107 2014-02-19 16:40:32Z nevcairiel $ | 12 -- @release $Id: AceComm-3.0.lua 1174 2018-05-14 17:29:49Z h.leppkes@gmail.com $ | 
| 13 | 13 | 
| 14 --[[ AceComm-3.0 | 14 --[[ AceComm-3.0 | 
| 15 | 15 | 
| 16 TODO: Time out old data rotting around from dead senders? Not a HUGE deal since the number of possible sender names is somewhat limited. | 16 TODO: Time out old data rotting around from dead senders? Not a HUGE deal since the number of possible sender names is somewhat limited. | 
| 17 | 17 | 
| 18 ]] | 18 ]] | 
| 19 | 19 | 
| 20 local MAJOR, MINOR = "AceComm-3.0", 9 | 20 local CallbackHandler = LibStub("CallbackHandler-1.0") | 
| 21 | 21 local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib") | 
| 22 | |
| 23 local MAJOR, MINOR = "AceComm-3.0", 12 | |
| 22 local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR) | 24 local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR) | 
| 23 | 25 | 
| 24 if not AceComm then return end | 26 if not AceComm then return end | 
| 25 | |
| 26 local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0") | |
| 27 local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib") | |
| 28 | 27 | 
| 29 -- Lua APIs | 28 -- Lua APIs | 
| 30 local type, next, pairs, tostring = type, next, pairs, tostring | 29 local type, next, pairs, tostring = type, next, pairs, tostring | 
| 31 local strsub, strfind = string.sub, string.find | 30 local strsub, strfind = string.sub, string.find | 
| 32 local match = string.match | 31 local match = string.match | 
| 64 end | 63 end | 
| 65 | 64 | 
| 66 if #prefix > 16 then -- TODO: 15? | 65 if #prefix > 16 then -- TODO: 15? | 
| 67 error("AceComm:RegisterComm(prefix,method): prefix length is limited to 16 characters") | 66 error("AceComm:RegisterComm(prefix,method): prefix length is limited to 16 characters") | 
| 68 end | 67 end | 
| 69 RegisterAddonMessagePrefix(prefix) | 68 if C_ChatInfo then | 
| 69 C_ChatInfo.RegisterAddonMessagePrefix(prefix) | |
| 70 else | |
| 71 RegisterAddonMessagePrefix(prefix) | |
| 72 end | |
| 70 | 73 | 
| 71 return AceComm._RegisterComm(self, prefix, method) -- created by CallbackHandler | 74 return AceComm._RegisterComm(self, prefix, method) -- created by CallbackHandler | 
| 72 end | 75 end | 
| 73 | 76 | 
| 74 local warnedPrefix=false | 77 local warnedPrefix=false | 
| 84 function AceComm:SendCommMessage(prefix, text, distribution, target, prio, callbackFn, callbackArg) | 87 function AceComm:SendCommMessage(prefix, text, distribution, target, prio, callbackFn, callbackArg) | 
| 85 prio = prio or "NORMAL" -- pasta's reference implementation had different prio for singlepart and multipart, but that's a very bad idea since that can easily lead to out-of-sequence delivery! | 88 prio = prio or "NORMAL" -- pasta's reference implementation had different prio for singlepart and multipart, but that's a very bad idea since that can easily lead to out-of-sequence delivery! | 
| 86 if not( type(prefix)=="string" and | 89 if not( type(prefix)=="string" and | 
| 87 type(text)=="string" and | 90 type(text)=="string" and | 
| 88 type(distribution)=="string" and | 91 type(distribution)=="string" and | 
| 89 (target==nil or type(target)=="string") and | 92 (target==nil or type(target)=="string" or type(target)=="number") and | 
| 90 (prio=="BULK" or prio=="NORMAL" or prio=="ALERT") | 93 (prio=="BULK" or prio=="NORMAL" or prio=="ALERT") | 
| 91 ) then | 94 ) then | 
| 92 error('Usage: SendCommMessage(addon, "prefix", "text", "distribution"[, "target"[, "prio"[, callbackFn, callbackarg]]])', 2) | 95 error('Usage: SendCommMessage(addon, "prefix", "text", "distribution"[, "target"[, "prio"[, callbackFn, callbackarg]]])', 2) | 
| 93 end | 96 end | 
| 94 | 97 | 
