Search code examples
luaworld-of-warcraft

Raid doesn't receive C_ChatInfo.SendAddonMessage


I'm making this addons that have to send to the raid my interrupt cooldown.
The problem is that whenever i send a message to the raid i am the only one that receive it.
This is the code that send the message:

C_ChatInfo.SendAddonMessage("KickRotation",string.format( "%0.2f",remainingCd ), "RAID")

This is the event handler:

frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("CHAT_MSG_ADDON")
frame:SetScript("OnEvent", function(self, event, ...)
    local prefix, msg, msgType, sender = ...;
    if event == "CHAT_MSG_ADDON" then
        if prefix == "KickRotation" then
            print("[KickRotation]" ..tostring(sender) .." potrà interrompere tra: " ..msg);
        end
    end
    if event == "PLAYER_ENTERING_WORLD" then
        print("[KickRotation] v0.1 by Galfrad")
    end 
end)

Basically when the message is sended it is printed only to me.


Solution

  • Network messages are handled and transferred to the recipient channel (in this case, Raid Group) by the server. The reason that you are seeing the message locally, but the other people do not see it is that the message will be handled on the local system (sender) to reduce the repetition of data transmit.

    Server however, only accepts and sends messages that are registered to it. Therefore, you must first register your add-on messages to the server so the other players in the requested channel be able to receive it.

    First, register your add-on messages with the name you have given already (But be sure to call the registration method only once per client):

    local success = C_ChatInfo.RegisterAddonMessagePrefix("KickRotation") -- Addon name.
    

    Next, check if your message was accepted and registered to the server. In case success is set to false (failure), you may want to handle proper warning messages and notifications to the user. The case of failure means that either server has disabled add-on messages or you have reached the limit of add-on message registrations.

    Finally, send your message again check if it did not fail.

    if not C_ChatInfo.SendAddonMessage("KickRotation",string.format( "%0.2f",remainingCd ), "RAID") then
        print("[KickRotation] Failed to send add-on message, message rejected by the server.")
    end