View Single Post
07-02-19, 10:11 PM   #1
Aeriez
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
Addon Comms with AceComm 3

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:
  1. local _, core = ...;
  2. local _G = _G;
  3. local MyAddon = core.MyAddon;
  4.  
  5. MyAddon.Sync = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceComm-3.0")
  6.  
  7. local LibAceSerializer = LibStub:GetLibrary("AceSerializer-3.0")
  8. local LibCompress = LibStub:GetLibrary("LibCompress")
  9. local LibCompressAddonEncodeTable = LibCompress:GetAddonEncodeTable()
  10.  
  11. function MyAddon.Sync:OnEnable()
  12.     MyAddon.Sync:RegisterComm("MyAddonDataSync", MyAddon.Sync:OnCommReceived())
  13. end
  14.  
  15. function MyAddon.Sync:OnCommReceived(prefix, message, distribution, sender)
  16.     local success, deserialized = LibAceSerializer:Deserialize(message);
  17.     if success then
  18.         print(deserialized)
  19.     end
  20. end
  21.  
  22. function MyAddon.Sync:SendData(data)
  23.     local serialized = nil
  24.     if data then
  25.         serialized = LibAceSerializer:Serialize(data)
  26.     end
  27.    
  28.     -- send the message
  29.     MyAddon.Sync:SendCommMessage("MonDKPDataSync", serialized, "PARTY")
  30. 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?

Last edited by Aeriez : 07-02-19 at 10:27 PM.
  Reply With Quote