jaxim
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018
04:42 AM
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
@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
2 REPLIES 2
tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018
09:11 AM
Re: Creating an Event handler for a roUrlTransfer
search these forums, there are some solid examples
jaxim
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018
12:07 PM
Re: Creating an Event handler for a roUrlTransfer
Can you provide a quick example?