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: 
jaxim
Visitor

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 2
tim_beynart
Channel Surfer

Re: Creating an Event handler for a roUrlTransfer

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

Re: Creating an Event handler for a roUrlTransfer

Can you provide a quick example?
0 Kudos