@ -14,7 +14,7 @@ TSMAPI.AuctionScan = {}
local RETRY_DELAY = 2
local MAX_RETRIES = 4
local BASE_DELAY = 0.10 -- time to delay for before trying to scan a page again when it isn't fully loaded
local private = { callbackHandler = nil , query = { } , options = { } , data = { } , isScanning = nil }
local private = { callbackHandler = nil , query = { } , options = { } , data = { } , isScanning = nil , isPaused = nil }
TSMAPI : RegisterForTracing ( private , " TradeSkillMaster.AuctionScanning_private " )
local scanCache = { }
@ -147,6 +147,7 @@ function TSMAPI.AuctionScan:RunQuery(query, callbackHandler, resolveSellers, max
-- setup other stuff
wipe ( private.data )
private.isScanning = true
private.isPaused = nil
private.callbackHandler = callbackHandler
private.resolveSellers = resolveSellers
private.scanType = " query "
@ -179,6 +180,7 @@ function TSMAPI.AuctionScan:ScanLastPage(callbackHandler)
-- setup other stuff
wipe ( private.data )
private.isScanning = true
private.isPaused = nil
private.callbackHandler = callbackHandler
private.scanType = " lastPage "
@ -189,7 +191,7 @@ end
-- sends a query to the AH frame once it is ready to be queried (uses frame as a delay)
function private : SendQuery ( )
if not private.isScanning then return end
if not private.isScanning or private.isPaused then return end
if CanSendAuctionQuery ( ) then
-- stop delay timer
@ -208,7 +210,7 @@ end
--scans the currently shown page of auctions and collects all the data
function private : ScanAuctions ( )
if not private.isScanning then return end
if not private.isScanning or private.isPaused then return end
local shown , total = GetNumAuctionItems ( " list " )
local totalPages = ceil ( total / NUM_AUCTION_ITEMS_PER_PAGE )
@ -303,6 +305,9 @@ function private:ScanAuctions()
end
-- query the next page and continue scanning
if private.isPaused then
return
end
private : SendQuery ( )
end
@ -363,6 +368,7 @@ function private:StopScanning()
TSMAPI : CancelFrame ( " updateDelay " )
AuctionScanning : UnregisterEvent ( " AUCTION_ITEM_LIST_UPDATE " )
private.isScanning = nil
private.isPaused = nil
private.pageTemp = nil
end
@ -373,6 +379,26 @@ function TSMAPI.AuctionScan:StopScan()
TSM : StopGeneratingQueries ( )
end
function TSMAPI . AuctionScan : PauseScan ( )
if not private.isScanning or private.isPaused then return false end
private.isPaused = true
TSMAPI : CancelFrame ( " queryDelay " )
TSMAPI : CancelFrame ( " updateDelay " )
AuctionScanning : UnregisterEvent ( " AUCTION_ITEM_LIST_UPDATE " )
return true
end
function TSMAPI . AuctionScan : ResumeScan ( )
if not private.isScanning or not private.isPaused then return false end
private.isPaused = nil
private : SendQuery ( )
return true
end
function TSMAPI . AuctionScan : IsPaused ( )
return private.isPaused and true or false
end
-- Gets the number of pages for a given query
function TSMAPI . AuctionScan : GetNumPages ( query , callbackHandler )
@ -422,6 +448,7 @@ function TSMAPI.AuctionScan:GetNumPages(query, callbackHandler)
-- setup other stuff
wipe ( private.data )
private.isScanning = true
private.isPaused = nil
private.callbackHandler = callbackHandler
private.scanType = " numPages "