OK, so I used to know what I was doing, but stoped developing since this Scene Graph thing came along. Now I'm trying to get up to speed and I'm having trouble understanding basic concepts, so I need the help of the forum.
I'm trying to create a simple task that downloads data from a url. I'm looking at the SimpleTask example and looking at what I'm typing up and I'm not seeing why I'm getting the error.
main.brs
sub Main()
showChannelSGScreen()
end sub
sub showChannelSGScreen()
print "in showChannelSGScreen"
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("SimpleVideoScene")
screen.show()
while(true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end while
end sub
SimpleVideoScene.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Roku Corp. All Rights Reserved. -->
<component name="SimpleVideoScene" extends="Scene">
<children>
<Label
id="Details"
height="300"
width="1300"
font="font:MediumBoldSystemFont"
text="PUT DETAILS TEXT HERE"
wrap="true"
translation="[300,600]" />
</children>
<script type="text/brightscript" uri="pkg:/components/SimpleVideoScene.brs"/>
</component>
SimpleVideoScene.brs
sub init()
m.feed_task = createObject("roSGNode", "serverstatus")
m.feed_task.observeField("response", "onFeedResponse")
m.feed_task.observeField("error", "onFeedError")
m.feed_task.url = url
m.feed_task.control = "RUN"
end sub
[size=85][font=Helvetica Neue, Helvetica, Arial, sans-serif] [/font][/size]
sub onFeedError(obj)
? "Feed Error"
end sub
sub onFeedResponse(obj)
? "FEED RESPONSE"
end sub
serverstatus.xml
<?xml version="1.0" encoding="UTF-8"?>
<component name="serverstatus" extends = "Task" >
<interface>
<field id = "url" type = "string" />
<field id = "response" type = "string" />
<field id = "error" type = "string" />
</interface>
<script type="text/brightscript" uri="pkg:/components/tasks/serverstatus.brs"/>
</component>
serverstatus.brs
sub init()
m.top.functionname = "request"
m.top.response = ""
end sub
function request()
?" Request"
url = "www.url.net"
http = createObject("roUrlTransfer")
http.RetainBodyOnError(true)
port = createObject("roMessagePort")
http.setPort(port)
http.setCertificatesFile("common:/certs/ca-bundle.crt")
http.InitClientCertificates()
http.enablehostverification(false)
http.enablepeerverification(false)
http.setUrl(url)
if http.AsyncGetToString() Then
msg = wait(10000, port)
if (type(msg) = "roUrlEvent")
if (msg.getresponsecode() > 0 and msg.getresponsecode() < 400)
m.top.response = msg.getstring()
else
m.top.error = "Feed failed to load. "+ chr(10) + msg.getfailurereason() + chr(10) + "Code: "+msg.getresponsecode().toStr()+ chr(10) + "URL: "+ m.top.url
end if
http.asynccancel()
else if (msg = invalid)
?
m.top.error = "Feed failed to load. Unknown reason."
http.asynccancel()
end if
end if
return 0
end function
Debug
------ Running dev 'SimpleVideoPlayer' main ------
in showChannelSGScreen
BRIGHTSCRIPT: ERROR: roSGNode: Failed to create roSGNode with type serverstatus: pkg:/components/SimpleVideoScene.brs(6)
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.
Suspending threads...
Thread selected: 1* ...mponents/SimpleVideoScene.brs(7) m.feed_task.observeField("response", "onFeedResponse")
Current Function:
004: sub init()
005:
006: m.feed_task = createObject("roSGNode", "serverstatus")
007:* m.feed_task.observeField("response", "onFeedResponse")
008: m.feed_task.observeField("error", "onFeedError")
009: m.feed_task.url = url
010: m.feed_task.control = "RUN"
011:
Interface not a member of BrightScript Component (runtime error &hf3) in pkg:/components/SimpleVideoScene.brs(7)
007: m.feed_task.observeField("response", "onFeedResponse")
Backtrace:
#0 Function init() As Void
file/line: pkg:/components/SimpleVideoScene.brs(7)
Local Variables:
global Interface:ifGlobal
m roAssociativeArray refcnt=2 count:3
url <uninitialized>
Threads:
ID Location Source Code
0 pkg:/source/main.brs(11) screen.show()
1* ...mponents/SimpleVideoScene.brs(7) m.feed_task.observeField("response", "onFeedResponse")
*selected
I've done a search, but didn't turn up anything to help me.