Throttle on joining/leaving channels?

Throttle on joining/leaving channels?

by Andraxion » Wed Apr 06, 2016 3:37 pm

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?
Tinkleflower (PvE)
Andraxion's Addon Collection [Updated and refreshed]
Taking requests for backporting addons to 1.12, though I cannot give timeframes and I'm not currently undertaking very large projects.
User avatar
Andraxion
Grunt
Grunt
 

Re: Throttle on joining/leaving channels?

by AfterAfterlife » Wed Apr 06, 2016 3:45 pm

Have you tried making a small timer between leaving and joining the channel?
AfterAfterlife
Grunt
Grunt
 

Re: Throttle on joining/leaving channels?

by Andraxion » Wed Apr 06, 2016 3:50 pm

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.
Last edited by Andraxion on Wed Apr 06, 2016 4:02 pm, edited 1 time in total.
Tinkleflower (PvE)
Andraxion's Addon Collection [Updated and refreshed]
Taking requests for backporting addons to 1.12, though I cannot give timeframes and I'm not currently undertaking very large projects.
User avatar
Andraxion
Grunt
Grunt
 

Re: Throttle on joining/leaving channels?

by AfterAfterlife » Wed Apr 06, 2016 3:59 pm

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).
AfterAfterlife
Grunt
Grunt
 

Re: Throttle on joining/leaving channels?

by Andraxion » Wed Apr 06, 2016 4:08 pm

Sweet, thanks. I'll try it out when I get home.
Tinkleflower (PvE)
Andraxion's Addon Collection [Updated and refreshed]
Taking requests for backporting addons to 1.12, though I cannot give timeframes and I'm not currently undertaking very large projects.
User avatar
Andraxion
Grunt
Grunt
 


Return to Addons & macros