how to detect if there is a network.download() connection running in the background

is there a way to detect if there is an active network.download() connection?

what i’m trying to do is:

  1. if there is a network.download() running in background, wait for it to finish.
  2. if not, then network.download() [import]uid: 71024 topic_id: 23432 reply_id: 323432[/import]

See here for info you can grab: http://developer.anscamobile.com/reference/index/network

Peach :slight_smile: [import]uid: 52491 topic_id: 23432 reply_id: 94036[/import]

Thanks, but sockets tend to freeze the app every time something is downloaded. I prefer to use network.download() because I can have one running in the background while the app does something else. [import]uid: 71024 topic_id: 23432 reply_id: 94145[/import]

This is what I have right now. I need some help figuring out why it hangs the app when it tries to download the first file:

[lua]local allDone = false
local isAvailable = true
local count = 1

local listener = function(event)
if (event.isError) then
print("Unable to download " … event.response)
else
print("Successfully downloaded " … event.response)

isAvailable = true

if (count == #files) then
allDone = true
else
count = count + 1
end
end
end

while (not allDone) do
local filename = files[count]

if (isAvailable) then
print("Downloading " … filename)

isAvailable = false
network.download(url … filename, “GET”, listener, filename)
end
end[/lua] [import]uid: 71024 topic_id: 23432 reply_id: 94550[/import]