I'm in the process of creating an addon that needs to have some form of internet communication to function. I have all of the communication done, but am getting a blocked UI whenever waiting for a response.
I am new to LUA and was just wondering if there was any form of asynchronous callbacks / background thread that can be done.
Here's what the code looks like now..
function printItemPrices(itemID) local tcp = assert(socket.tcp()) tcp:connect(host, port) tcp:send("GET /AHPrice/GetNamePriceForID.aspx?id=" .. itemID .. " HTTP/1.0\r\n\r\n") lastLine = '' local loopCount = 0 --This is where i am freezing while true do local s, status, partial = tcp:receive() lastLine = s or partial if status == "closed" or status == "Socket is not connected" then break end end tcp:close() tcp:shutdown("both") if (string.match(lastLine, ",")) then --handle response end end