@@ -1753,19 +1753,21 @@ function Comm.RequestSelfBotState(callback)
17531753 return false
17541754 end
17551755
1756- safeDelay (SELF_BOT_TIMEOUT_SECONDS , function ()
1757- local bridge = ensureBridgeState ()
1758- local pending = bridge .selfBotStateActive
1759- if type (pending ) ~= " table" or pending .token ~= token then
1760- return
1761- end
1756+ if MultiBot and type (MultiBot .TimerAfter ) == " function" then
1757+ MultiBot .TimerAfter (SELF_BOT_TIMEOUT_SECONDS , function ()
1758+ local bridge = ensureBridgeState ()
1759+ local pending = bridge .selfBotStateActive
1760+ if type (pending ) ~= " table" or pending .token ~= token then
1761+ return
1762+ end
17621763
1763- finishSelfBotRequest (" state" , token , {
1764- status = " timeout" ,
1765- active = type (bridge .selfBotLastActive ) == " boolean" and bridge .selfBotLastActive or nil ,
1766- reason = " TIMEOUT" ,
1767- })
1768- end )
1764+ finishSelfBotRequest (" state" , token , {
1765+ status = " timeout" ,
1766+ active = type (bridge .selfBotLastActive ) == " boolean" and bridge .selfBotLastActive or nil ,
1767+ reason = " TIMEOUT" ,
1768+ })
1769+ end )
1770+ end
17691771
17701772 return token
17711773end
@@ -1785,7 +1787,13 @@ function Comm.RunSelfBot(desiredState, callback)
17851787 end
17861788
17871789 -- A state response created before this mutation is stale by definition.
1788- state .selfBotStateActive = nil
1790+ local staleState = state .selfBotStateActive
1791+ if type (staleState ) == " table" then
1792+ finishSelfBotRequest (" state" , staleState .token , {
1793+ status = " error" ,
1794+ reason = " SUPERSEDED" ,
1795+ })
1796+ end
17891797
17901798 state .selfBotCommandSeq = (tonumber (state .selfBotCommandSeq ) or 0 ) + 1
17911799 local token = tostring (math.floor (safeNow () * 1000 ))
@@ -1803,20 +1811,22 @@ function Comm.RunSelfBot(desiredState, callback)
18031811 return false
18041812 end
18051813
1806- safeDelay (SELF_BOT_TIMEOUT_SECONDS , function ()
1807- local bridge = ensureBridgeState ()
1808- local pending = bridge .selfBotCommandActive
1809- if type (pending ) ~= " table" or pending .token ~= token then
1810- return
1811- end
1814+ if MultiBot and type (MultiBot .TimerAfter ) == " function" then
1815+ MultiBot .TimerAfter (SELF_BOT_TIMEOUT_SECONDS , function ()
1816+ local bridge = ensureBridgeState ()
1817+ local pending = bridge .selfBotCommandActive
1818+ if type (pending ) ~= " table" or pending .token ~= token then
1819+ return
1820+ end
18121821
1813- finishSelfBotRequest (" command" , token , {
1814- status = " timeout" ,
1815- active = type (bridge .selfBotLastActive ) == " boolean" and bridge .selfBotLastActive or nil ,
1816- reason = " TIMEOUT" ,
1817- desiredState = pending .desiredState ,
1818- })
1819- end )
1822+ finishSelfBotRequest (" command" , token , {
1823+ status = " timeout" ,
1824+ active = type (bridge .selfBotLastActive ) == " boolean" and bridge .selfBotLastActive or nil ,
1825+ reason = " TIMEOUT" ,
1826+ desiredState = pending .desiredState ,
1827+ })
1828+ end )
1829+ end
18201830
18211831 return token
18221832end
@@ -5135,6 +5145,9 @@ function Comm.HandleAddonMessage(prefix, message, distribution, sender)
51355145 state .capabilitiesResolved = true
51365146 debugPrint (" ADDON:RX" , " CAPS" , payload or " " )
51375147 flushPendingStateRefreshes ()
5148+ if state .selfBotCapable == true and type (Comm .RequestSelfBotState ) == " function" then
5149+ Comm .RequestSelfBotState ()
5150+ end
51385151 if MultiBot .RefreshEnchantingEveryButtons then
51395152 MultiBot .RefreshEnchantingEveryButtons ()
51405153 end
@@ -5152,6 +5165,9 @@ function Comm.HandleAddonMessage(prefix, message, distribution, sender)
51525165 state .capabilitiesResolved = true
51535166 debugPrint (" ADDON:RX" , " CAPS_END" )
51545167 flushPendingStateRefreshes ()
5168+ if state .selfBotCapable == true and type (Comm .RequestSelfBotState ) == " function" then
5169+ Comm .RequestSelfBotState ()
5170+ end
51555171 if MultiBot .RefreshEnchantingEveryButtons then
51565172 MultiBot .RefreshEnchantingEveryButtons ()
51575173 end
0 commit comments