Hi All,
I am trying to achieve a case of firing multiple http requests ( async ) one after another in a loop to receive content asynchronously whenever they arrive but when i try with roUrlTransfer it seems to cancel the previous request and succeeds only when for the last request. Could a case like this be doable at all ? Any suggestions to implement a case like this is welcome.
Here's my code :
port = CreateObject("roMessagePort")
uri = [ "http://www.naturalengland.org.uk/Images/drywalls_tcm6-9377.jpg", "http://www.visual-arts-cork.com/images-paint/constable-haywain.jpg" ]
for each imgURI in uri
imgObj = { id: invalid, bitmap: invalid, size: { w: 200, h: 200 }, uri: imgURI, status: invalid }
images.push(imgObj)
end for
' Request Images through roURL
for each img in images
' Tried it without having http = invalid. Produced the same result.
http = invalid
http = CreateObject("roUrlTransfer")
http.SetPort(port)
http.SetUrl(img.uri)
filePath = "tmp:/" + util_md5(img.uri)
img.status = http.AsyncGetToFile(filePath)
print "Status is "; img.status
img.id = http.GetIdentity()
end for
While True
msg = wait(0, port)
textureFlag = false
if msg <> invalid
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
print "Code is "; code
if code = 200
textureFlag = true
for each img in images
if img.id = msg.GetSourceIdentity()
img.bitmap = true
end if
end for
else if code = -10001
print "Error is"; msg.GetFailureReason()
end if
end if
end if
End While