Verify request ID on receive events
This commit is contained in:
@ -108,7 +108,7 @@ function CMH.OnReceive(self, event, prefix, _, Type, sender)
|
|||||||
if event == "CHAT_MSG_ADDON" and sender == UnitName("player") and Type == "WHISPER" then
|
if event == "CHAT_MSG_ADDON" and sender == UnitName("player") and Type == "WHISPER" then
|
||||||
-- unpack and validate addon message structure
|
-- unpack and validate addon message structure
|
||||||
local pfx, source, pckId, data = prefix:match("(...)(%u)(%d%d)(.+)")
|
local pfx, source, pckId, data = prefix:match("(...)(%u)(%d%d)(.+)")
|
||||||
if not pfx or not source or not pckId or not data then
|
if not pfx or not source or not pckId then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -186,7 +186,12 @@ function CMH.OnREQ(sender, data)
|
|||||||
CMH.SendACK(reqId)
|
CMH.SendACK(reqId)
|
||||||
end
|
end
|
||||||
|
|
||||||
function CMH.OnACK(sender, reqId)
|
function CMH.OnACK(sender, data)
|
||||||
|
local reqId = data:match("(%w%w%w%w%w%w)");
|
||||||
|
if not reqId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- We received ACK but no data is available in cache. This should never happen
|
-- We received ACK but no data is available in cache. This should never happen
|
||||||
if not datacache[reqId] then
|
if not datacache[reqId] then
|
||||||
debugOut("ACK received but no data available to transmit. Aborting.")
|
debugOut("ACK received but no data available to transmit. Aborting.")
|
||||||
@ -255,7 +260,12 @@ function CMH.OnDAT(sender, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function CMH.OnNAK(sender, reqId)
|
function CMH.OnNAK(sender, data)
|
||||||
|
local reqId = data:match("(%w%w%w%w%w%w)");
|
||||||
|
if not reqId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- when we receive an error from the server, purge the local cache data
|
-- when we receive an error from the server, purge the local cache data
|
||||||
debugOut("Purging cache data with REQ ID: "..reqId)
|
debugOut("Purging cache data with REQ ID: "..reqId)
|
||||||
datacache[reqId] = nil
|
datacache[reqId] = nil
|
||||||
|
|||||||
@ -197,7 +197,12 @@ function SMH.OnREQ(sender, data)
|
|||||||
SMH.SendACK(sender, reqId)
|
SMH.SendACK(sender, reqId)
|
||||||
end
|
end
|
||||||
|
|
||||||
function SMH.OnACK(sender, reqId)
|
function SMH.OnACK(sender, data)
|
||||||
|
local reqId = data:match("(%w%w%w%w%w%w)");
|
||||||
|
if not reqId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- We received ACK but no data is available in cache. This should never happen
|
-- We received ACK but no data is available in cache. This should never happen
|
||||||
if not datacache[sender:GetGUIDLow()][reqId] then
|
if not datacache[sender:GetGUIDLow()][reqId] then
|
||||||
debugOut("ACK received but no data available to transmit. Aborting.")
|
debugOut("ACK received but no data available to transmit. Aborting.")
|
||||||
@ -266,7 +271,12 @@ function SMH.OnDAT(sender, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SMH.OnNAK(sender, reqId)
|
function SMH.OnNAK(sender, data)
|
||||||
|
local reqId = data:match("(%w%w%w%w%w%w)");
|
||||||
|
if not reqId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- when we receive an error from the server, purge the local cache data
|
-- when we receive an error from the server, purge the local cache data
|
||||||
debugOut("Purging cache data with REQ ID: "..reqId)
|
debugOut("Purging cache data with REQ ID: "..reqId)
|
||||||
datacache[sender:GetGUIDLow()][reqId] = nil
|
datacache[sender:GetGUIDLow()][reqId] = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user