Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Async URL Requests?

The roUrlTransfer has the AsyncGetToString method which performs async requests. However, in order to receive events from this, you must wait on a message port associated with it. The waits are blocking, so how is this truly async, or am I missing something?
0 Kudos
5 REPLIES 5
RokuMarkn
Visitor

Re: Async URL Requests?

You can do other work before you wait for the transfer events. You can do a non-blocking poll by waiting with a short timeout so that you can check if the transfer is complete and do something else if it isn't done yet.

--Mark
0 Kudos

Re: Async URL Requests?

"RokuMarkn" wrote:
You can do other work before you wait for the transfer events. You can do a non-blocking poll by waiting with a short timeout so that you can check if the transfer is complete and do something else if it isn't done yet.

--Mark



Are messages sent to a port cached? Maybe this was my misunderstanding. I thought that if an event occurred without a Wait happening, then it was lost. Is there any documentation about BrightScript that explains the technical implementations and semantics of the components? Thanks for the help, Mark.

- Jordan
0 Kudos
TheEndless
Channel Surfer

Re: Async URL Requests?

If you assign the same message port to the roUrlTransfer component that your current screen is using, then you can receive its events within the same Wait loop that you already have running, so you don't have to block while waiting for the response.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
RokuMarkn
Visitor

Re: Async URL Requests?

That's correct, and that's usually the best way to handle async requests.
Also, an event is not lost if you're not waiting when it occurs. The event is queued and delivered the next time you wait.

--Mark
0 Kudos
belltown
Roku Guru

Re: Async URL Requests?

"TheEndless" wrote:
If you assign the same message port to the roUrlTransfer component that your current screen is using, then you can receive its events within the same Wait loop that you already have running, so you don't have to block while waiting for the response.

Congratulations, TheEndless, on your 5,000th post. It looks like you've imparted an endless stream of useful information in that time.
0 Kudos