So I've been picking through AceComm 3.0 in conjunction with AceSerializer. I've managed to start to figure out how it's working. However, when I reload the UI, it always triggers OnCommReceived() once on reload/login with no values. IE: print(prefix, message, sender) at the start of OnCommReceived() returns nil nil nil.
It only does it once when the game is loaded in. After that it seems to work fine, sending messages on demand and never nil values. However, that initial set of nil values is where it's breaking AceSerializer. I'm able to serialize and send, but if I attempt to deserialize, it tries passing that nil value on reload/login and breaks the Lib entirely and can no longer be used. Error stating the Deserialize function expected a string but got the nil value. Any insight into what is causing that initial SendCommMessage to fire off?
Oh, and as an added note, it's only the root client that's receiving the nil values. Other clients in the group that receive the messages do not ever see it unless they themselves reload.
Lua Code:
local _, core = ...;
local _G = _G;
local MyAddon = core.MyAddon;
MyAddon.Sync = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceComm-3.0")
local LibAceSerializer = LibStub:GetLibrary("AceSerializer-3.0")
local LibCompress = LibStub:GetLibrary("LibCompress")
local LibCompressAddonEncodeTable = LibCompress:GetAddonEncodeTable()
function MyAddon.Sync:OnEnable()
MyAddon.Sync:RegisterComm("MyAddonDataSync", MyAddon.Sync:OnCommReceived())
end
function MyAddon.Sync:OnCommReceived(prefix, message, distribution, sender)
local success, deserialized = LibAceSerializer:Deserialize(message);
if success then
print(deserialized)
end
end
function MyAddon.Sync:SendData(data)
local serialized = nil
if data then
serialized = LibAceSerializer:Serialize(data)
end
-- send the message
MyAddon.Sync:SendCommMessage("MonDKPDataSync", serialized, "PARTY")
end
EDIT: I did work around it by filtering it through if prefix ~= nil. But is that the only way to really ignore it? Or is the initial failure a deeper bug on my behalf?