comparison Libs/AceComm-3.0/AceComm-3.0.lua @ 58:0682d738499b v8.0.1.058

- 8.0.1 Update.
author Tercio
date Fri, 20 Jul 2018 19:04:12 -0300
parents dbf04157d63e
children
comparison
equal deleted inserted replaced
57:b1c62eed8999 58:0682d738499b
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 1161 2017-08-12 14:30:16Z funkydude $ 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 CallbackHandler = LibStub("CallbackHandler-1.0") 20 local CallbackHandler = LibStub("CallbackHandler-1.0")
21 local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib") 21 local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib")
22 22
23 local MAJOR, MINOR = "AceComm-3.0", 10 23 local MAJOR, MINOR = "AceComm-3.0", 12
24 local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR) 24 local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR)
25 25
26 if not AceComm then return end 26 if not AceComm then return end
27 27
28 -- Lua APIs 28 -- Lua APIs
63 end 63 end
64 64
65 if #prefix > 16 then -- TODO: 15? 65 if #prefix > 16 then -- TODO: 15?
66 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")
67 end 67 end
68 RegisterAddonMessagePrefix(prefix) 68 if C_ChatInfo then
69 C_ChatInfo.RegisterAddonMessagePrefix(prefix)
70 else
71 RegisterAddonMessagePrefix(prefix)
72 end
69 73
70 return AceComm._RegisterComm(self, prefix, method) -- created by CallbackHandler 74 return AceComm._RegisterComm(self, prefix, method) -- created by CallbackHandler
71 end 75 end
72 76
73 local warnedPrefix=false 77 local warnedPrefix=false
83 function AceComm:SendCommMessage(prefix, text, distribution, target, prio, callbackFn, callbackArg) 87 function AceComm:SendCommMessage(prefix, text, distribution, target, prio, callbackFn, callbackArg)
84 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!
85 if not( type(prefix)=="string" and 89 if not( type(prefix)=="string" and
86 type(text)=="string" and 90 type(text)=="string" and
87 type(distribution)=="string" and 91 type(distribution)=="string" and
88 (target==nil or type(target)=="string") and 92 (target==nil or type(target)=="string" or type(target)=="number") and
89 (prio=="BULK" or prio=="NORMAL" or prio=="ALERT") 93 (prio=="BULK" or prio=="NORMAL" or prio=="ALERT")
90 ) then 94 ) then
91 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)
92 end 96 end
93 97