Page 1 of 1

Throttle on joining/leaving channels?

PostPosted: Wed Apr 06, 2016 3:37 pm
by Andraxion
I'm trying to circumvent the bugged out channels on login with an addon I started last night, but when it executes, it only leaves the channel but doesn't re-join. It will work when I run the commands individually, but they won't work in succession.

Code: Select all
function CL_Actions(cInfo)
    LeaveChannelByName(cInfo)
    JoinChannelByName(cInfo)
    CL_print("Reset channel [" .. cInfo .. "]")
end


cInfo is the argument where the specific channel name is being passed.

Anyone have any advice or experience with this?

Re: Throttle on joining/leaving channels?

PostPosted: Wed Apr 06, 2016 3:45 pm
by AfterAfterlife
Have you tried making a small timer between leaving and joining the channel?

Re: Throttle on joining/leaving channels?

PostPosted: Wed Apr 06, 2016 3:50 pm
by Andraxion
I did but I didnt have time to play around much with it. I'm at work now so I just figured I'd ask around until I can get back to it.

--edit--
A thought just occurred to me, I don't think it's rejoining the channel because perhaps leaving the channel doesn't take effect until the end of the current sequence or frame(or conversely, the beginning of the next). So the join can't join because, well, it's still technically in it.

I did notice some chat spam indicating that I was already in some channels(though not all) and didn't think anything of it in regards to this.

I'll try either just using the next onUpdate or setting a timer, if it doesn't work I'll be back.

Re: Throttle on joining/leaving channels?

PostPosted: Wed Apr 06, 2016 3:59 pm
by AfterAfterlife
I don't have a Vanilla client to test it, but try this whenever you can:

Code: Select all
local function CL_Actions(cInfo)
    LeaveChannelByName(cInfo)
   
   --creating timer
   local timer, startTime = CreateFrame("FRAME"), GetTime();
   timer:SetScript("OnUpdate", function()
      if(GetTime() - startTime > 500) then
         timer:SetScript("OnUpdate", nil);
         JoinChannelByName(cInfo)
      end
   end);

    CL_print("Reset channel [" .. cInfo .. "]")
end


Play with the interval (500 milliseconds, in this case).

Re: Throttle on joining/leaving channels?

PostPosted: Wed Apr 06, 2016 4:08 pm
by Andraxion
Sweet, thanks. I'll try it out when I get home.