Roku Developer Program

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

Creating an Event handler for a roUrlTransfer

I would like to do an asynchronous call to a server. The documentation has the following example to do that, but I am unsure where the HandleUrlEventO() event handler method gets called. The documentation mentions that "a roUrlEvent will be sent to the message port associated with the object". I assume that is how the HandleUrlEvent() event handler is called but I am unsure how to set up the port to do this. Can anyone assist?

@source: https://sdkdocs.roku.com/display/sdkdoc/ifUrlTransfer

Function Setup()
    m.pendingXfers = {}
End Function
 
Function GetAsync(url as String)
    newXfer = CreateObject("roUrlTransfer")
    newXfer.SetUrl(url)
    newXfer.AsyncGetToString()
    requestId = newXfer.GetIdentity().ToStr()
    m.pendingXfers[requestId] = newXfer
End Function
 
Function HandleUrlEvent(event as Object)
    requestId = event.GetSourceIdentity().ToStr()
    xfer = m.pendingXfers[requestId]
    if xfer <> invalid then
        ' process it
        m.pendingXfers.Delete(requestId)
    end if
End Function



0 Kudos
2 Replies
tim_beynart
Level 7

Re: Creating an Event handler for a roUrlTransfer

search these forums, there are some solid examples
0 Kudos
jaxim
Level 7

Re: Creating an Event handler for a roUrlTransfer

Can you provide a quick example?
0 Kudos