Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

***solved*** ASyncGetToFile fails immediately?

I have a URL (.cgi script) which is returning a .jpeg file. I can copy/paste the URL into my browser and see the image without issue.

But... when I pull that same URL via this code, it returns an INVALID event immediately.

' agent for transferring files
agent = CreateObject("roUrlTransfer")

print "About to AsyncGetToFile: "; settings.Url; " "; tmpFile

' get it
if (agent.AsyncGetToFile(tmpFile) = false) then
print "AsyncGetToFile never even started!"
end if

event = wait(30000,agent.GetMessagePort())

if type(event) = "roUrlEvent"
print "***";event.GetInt();
print "***";event.GetResponseCode();
print "***";event.GetFailureReason();
print "***";event.GetSourceIdentity()
else if event = invalid
print "AsyncGetToFile timeout"
print "AsyncGetToFile unknown event: "; event

I've seen some code using agent.GetPort() instead but the reference at only lists GetMessagePort()

Any help is appreciated.


agent = CreateObject("roUrlTransfer")
agentPort = CreateObject("roMessagePort")
0 Kudos
2 Replies
Level 8

Re: ASyncGetToFile fails immediately?

You need to create a message port and call agent.SetMessagePort().

0 Kudos
Level 7

Re: ASyncGetToFile fails immediately?

You're good people! I'm getting a different error now but at least I can tell it's trying to make a connection.

0 Kudos