AceComm SendCommMessage "target" won't accept number #419


  • New
Closed
  • fireymerlin created this issue Sep 26, 2017

    An edit in SendCommMessage prevents the usage of a number for the "target" parameter.

    When using a custom chat channel, the "target" parameter needs to be the channelID (a number) returned by GetChannelName("channel_name").

     

    I made a change to my copy of  SendCommMessage to allow "target" to be a number and everything works with using custom chat channels created with the

     

     JoinTemporaryChannel() API call.

     

  • fireymerlin added a tag New Sep 26, 2017
  • fireymerlin edited description Sep 26, 2017
  • nevcairiel posted a comment Oct 1, 2017

    SendCommMessage is a wrapper around SendAddonMessage, I don't think you can send those to custom channels.

    What kind of parameter would that be for type/distribution?

  • fireymerlin posted a comment Oct 1, 2017

    I verified, you can send to custom channels.  Also, I put in my issue that i changed "SendCommMessage" to allow target to be a number and it worked.  The number used is returned by:  GetChannelName("channel_name").

     

    Example:

    self.Prefix = 'MyPrefix"
    self.ChannelName = 'MyChannel'
    self.ChannelPassword = 'AbCd123'
    local _, _ = JoinTemporaryChannel(self.ChannelName ,self.ChannelPassword)
    self.ChannelID, _ = GetChannelName(self.ChannelName)
    self:SendCommMessage(self.Prefix, Data, 'CHANNEL', self.ChannelID)

     


    Edited Oct 1, 2017
  • hizuro_de posted a comment Oct 12, 2017

    Hi.

    I can confirm it. SendAddonMessage support use of custom channels. I've wrote following code for testing, shared it as addon with a guild member and it works.

    local C = WrapTextInColorCode;
    local frame = CreateFrame("frame");
    local prefix,chan,pw,id = "CCT-Px","CustomChannelTest","CustomChannelTest",false;
    
    frame:SetScript("OnEvent",function(self,event,...)
    	if event=="PLAYER_LOGIN" then
    		C_Timer.After(8,function()
    			if (RegisterAddonMessagePrefix(prefix)~=nil) and (JoinTemporaryChannel(chan,pw)~=nil) then
    				local chanId,chanName = GetChannelName(chan);
    				if chanId then
    					print(C("[Channel registered]","ffffee00"),"id="..C(chanId,"ff00ff00"));
    					SendAddonMessage(prefix,"channel-testing","CHANNEL",chanId);
    				end
    			end
    		end);
    	elseif event=="CHAT_MSG_ADDON" and prefix==... then
    		local _,msg,chType,toon,chLabel = ...;
    		print(C("[AddOnMsg]","ffffee00"), "player="..C(toon,"ff00aaff"), "chan="..C(chLabel,"ffff7700"), "msg="..C(msg,"ff00ff00"));
    	end
    end);
    
    frame:RegisterEvent("PLAYER_LOGIN");
    frame:RegisterEvent("CHAT_MSG_ADDON");

     

    Greetings Hizuro


    Edited Oct 12, 2017
  • fireymerlin posted a comment Oct 15, 2017

    I'm using ACE3 version: Ace3 Release - Revision r1166 (August 29th, 2017)
    which I got using the Twitch (Curse) desktop app.

    When I use a custom channel, I'm getting the following error:
    --------------------
    1x Census\Census-101.lua:3498: Usage: SendCommMessage(addon, "prefix", "text", "distribution"[, "target"[, "prio"[, callbackFn, callbackarg]]])
    [C]: ?
    Ace3\AceComm-3.0\AceComm-3.0-10.lua:91: in function `SendCommMessage'
    --------------------

    The error is caused by line 88 of AceComm-3.0.lua which is a part of a series of conditional statements with a NOT in front of it:
    (target==nil or type(target)=="string") and

    This throws an error if the "target", which is the channel number, is NOT of type "string".

    Census - is the name of the addon that I wrote.


    Edited Oct 15, 2017
  • nevcairiel closed issue May 14, 2018

To post a comment, please login or register a new account.