Arezth
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2017
04:52 PM
Using roUrlTransfer from within a scene
Hi Forum
I appreciate the help I've gotten so far from you. I came here with a new question. I've tried to create a roUrlTransfer from a scene I've loaded, but as expected it says it is invalid or unitialized. My main.brs is as followed:
Within this main.brs, I make a few calls using CreateObject("roUrlTransfer") without any problems, but when I tried to create this within my "HomeScene" it wasn't possible. After checking the forum it said that I should use interfaces in order to make the calls, but as far as I understood it can not be referenced directly (it seems roSgNode does not support objects). Global variable is not an option either. Some people create functions in order to make it happen, but I did not understand it fully ( https://forums.roku.com/viewtopic.php?f ... ne#p533154) Am I too far from the correct way? Can I get some guidance?
I appreciate the help I've gotten so far from you. I came here with a new question. I've tried to create a roUrlTransfer from a scene I've loaded, but as expected it says it is invalid or unitialized. My main.brs is as followed:
sub RunUserInterface()
screen = CreateObject("roSGScreen")
scene = screen.CreateScene("HomeScene")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()
....
scene.gridContent = ParseJsonContent(list)
...
while true
msg = wait(0, port)
print "--------- o --------"
print "msg = "; msg
print clock
end while
if screen <> invalid then
screen.Close()
screen = invalid
end if
end sub
Within this main.brs, I make a few calls using CreateObject("roUrlTransfer") without any problems, but when I tried to create this within my "HomeScene" it wasn't possible. After checking the forum it said that I should use interfaces in order to make the calls, but as far as I understood it can not be referenced directly (it seems roSgNode does not support objects). Global variable is not an option either. Some people create functions in order to make it happen, but I did not understand it fully ( https://forums.roku.com/viewtopic.php?f ... ne#p533154) Am I too far from the correct way? Can I get some guidance?
2 REPLIES 2
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2017
05:21 PM
Re: Using roUrlTransfer from within a scene
There are 3 kinds of contexts (sometimes referred to as "threads" because well, execution happens in different threads - which determines the limitations of the context): main, render and task. When function/code is executed in the scene graph render thread, no long-lasting calls are allowed since that thread is the one that redraws the screen tens of times per second - blocking that for e.g. waiting on network call means the screen freezing. Consequently, roUrlTransfer is banned from the render thread - which happens to be all functions/events (init()/onKeyEvent() etc) in a scene. Meaning, you have to do network calls either in the main thread or spin off a task for that.
Arezth
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2017
10:34 AM
Re: Using roUrlTransfer from within a scene
Thank you for your reply EnTerr, and sorry for the late reply, I believed I had already done it. I created a Task exclusively to make the calls to the server given your explanation and have worked perfectly so far! Thank you for taking your time explaining it!